Skip to content

Commit ee66b82

Browse files
committed
Use window.origin when fetching policies for inheriting special URLs (thanks NDevTK for reporting).
1 parent c4e15e2 commit ee66b82

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

src/content/staticNS.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@
5555

5656
fetchPolicy(sync = false) {
5757
if (this.policy) return;
58-
let url = document.URL;
58+
let url = window.location.href;
59+
let origin = window.origin;
5960

60-
debug(`Fetching policy from document %s, readyState %s`,
61-
url, document.readyState
62-
//, document.domain, document.baseURI, window.isSecureContext // DEV_ONLY
61+
debug(`Fetching policy from document %s (origin %s), readyState %s`,
62+
url, origin, document.readyState
6363
);
6464

6565
if (this.domPolicy) {
@@ -85,13 +85,9 @@
8585
return;
8686
}
8787

88-
if (url.startsWith("blob:")) {
89-
url = location.origin;
90-
} else if (/^(?:javascript|about):/.test(url)) {
91-
url = document.readyState === "loading" || !document.domain
92-
? document.baseURI
93-
: `${window.isSecureContext ? "https" : "http"}://${document.domain}`;
94-
debug("Fetching policy for actual URL %s (was %s)", url, document.URL);
88+
if (origin !== 'null' && window.location.origin !== origin) {
89+
debug("Fetching policy for actual URL %s (was %s)", origin, url);
90+
url = origin;
9591
}
9692

9793
if (!this.syncFetchPolicy) {

0 commit comments

Comments
 (0)