Skip to content

Commit 9a1432d

Browse files
committed
[UX] Honor non-contextual x-load capability granted from NoScript Options (thanks barbaz for RFE).
1 parent 889e1dc commit 9a1432d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/bg/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@
330330
let xLoadable;
331331
if (contextUrl.startsWith("file:")) {
332332
const contextDir = contextUrl.replace(/[^\/]*$/, '');
333-
const urls = [...policy.sites.keys()].filter(u => /^file:\/\/.*\//.test(u));
333+
const urls = [...policy.sites.keys()].filter(u => /^file:/.test(u));
334334
xLoadable = urls.filter(u =>
335335
policy.get(u, contextDir)?.perms?.capabilities.has("x-load"));
336336
}

src/content/staticNS.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ const FILE_OR_FTP = /^(?:file|ftp):$/.test(location.protocol);
178178
},
179179

180180
canXLoad(url) {
181-
return this.policy?.xLoadable?.includes(url.replace(/[^/]+$/, ""));
181+
return this.policy?.xLoadable?.some(parentDir => url.startsWith(parentDir));
182182
}
183183
};
184184
globalThis.ns = globalThis.ns ? Object.assign(ns, globalThis.ns) : ns;

0 commit comments

Comments
 (0)