summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorhackademix2018-08-21 23:51:59 +0200
committerhackademix2018-08-21 23:51:59 +0200
commit91334fe94477fdbcb85fcf93d87e3c73294da106 (patch)
tree34224a6b802e7aeceb420112ac257535800bdcbd /src/common
parente742e5d80102c01174d5d26d7b7c209fbd02cc9a (diff)
downloadnoscript-91334fe94477fdbcb85fcf93d87e3c73294da106.tar.gz
noscript-91334fe94477fdbcb85fcf93d87e3c73294da106.tar.xz
noscript-91334fe94477fdbcb85fcf93d87e3c73294da106.zip
Fixed inconstitencies in ChildPolicies content script URL matching.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/Policy.js21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/common/Policy.js b/src/common/Policy.js
index 6adc2ae..24c3179 100644
--- a/src/common/Policy.js
+++ b/src/common/Policy.js
@@ -20,7 +20,26 @@ var {Permissions, Policy, Sites} = (() => {
static isValid(site) {
return /^(?:https?:(?:\/\/)?)?([\w\u0100-\uf000][\w\u0100-\uf000.-]*)?[\w\u0100-\uf000](?::\d+)?$/.test(site);
}
-
+
+
+ static originImplies(originKey, site) {
+ return originKey === site || site.startsWith(`${originKey}/`);
+ }
+ static domainImplies(domainKey, site, protocol = null) {
+ if (!protocol) {
+ return (Sites.isSecureDomainKey(domainKey))
+ ? Sites.domainImplies(Sites.toggleSecureDomainKey(domainKey, false), site, "https")
+ : ["http", "https"].some(protocol => Sites.domainImplies(domainKey, site, protocol));
+ }
+ return Sites.originImplies(`${protocol}://${domainKey}`, site);
+ }
+
+ static isImplied(site, byKey) {
+ return byKey.includes("://")
+ ? Sites.originImplies(byKey, site)
+ : Sites.domainImplies(byKey, site);
+ }
+
static parse(site) {
let url, siteKey = "";
if (site instanceof URL) {