Fix: Sites.domainImplies() should match subdomains.

This commit is contained in:
hackademix 2018-08-22 18:02:44 +02:00
parent 075a5ad0e0
commit 66ddfcbecc
1 changed files with 7 additions and 6 deletions

View File

@ -25,13 +25,14 @@ var {Permissions, Policy, Sites} = (() => {
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));
static domainImplies(domainKey, site, protocol ="https?") {
if (Sites.isSecureDomainKey(domainKey)) {
protocol = "https";
domainKey = Sites.toggleSecureDomainKey(domainKey, false);
}
return Sites.originImplies(`${protocol}://${domainKey}`, site);
return new RegExp(`^${protocol}://([^/?#:]+\\.)?${domainKey.replace(/\./g, "\\.")}(?:[:/]|$)`)
.test(site);
}
static isImplied(site, byKey) {