Skip to content

Commit

Permalink
send credentials if requested
Browse files Browse the repository at this point in the history
  • Loading branch information
samthor committed May 29, 2018
1 parent c5d6328 commit ee53e70
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
19 changes: 13 additions & 6 deletions pwacompat.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@

(function() {
if (!('fetch' in window)) {
return;
} else if (document.readyState === 'complete') {
setup();
} else {
window.addEventListener('load', setup);
return; // basic feature detection: from Mobile Safari 10.3+
}

const capableDisplayModes = ['standalone', 'fullscreen', 'minimal-ui'];
Expand All @@ -44,7 +40,11 @@
if (!manifestHref) {
throw `can't find <link rel="manifest" href=".." />'`;
}
return window.fetch(manifestHref);
const opts = /** @type {!RequestInit} */ ({});
if (manifestHref.crossOrigin === 'use-credentials') {
opts.credentials = 'include';
}
return window.fetch(manifestHref, opts);
})
.then((response) => response.json())
.then((data) => process(data, manifestHref))
Expand Down Expand Up @@ -252,4 +252,11 @@
canvas.height = height;
return canvas.getContext('2d');
}

// actually run PWACompat here
if (document.readyState === 'complete') {
setup();
} else {
window.addEventListener('load', setup);
}
}());
14 changes: 7 additions & 7 deletions pwacompat.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ee53e70

Please sign in to comment.