Index: lib/filterClasses.js |
=================================================================== |
--- a/lib/filterClasses.js |
+++ b/lib/filterClasses.js |
@@ -477,54 +477,58 @@ |
// upper-case to avoid false positives here. Instead we need to |
// change the way filter options are parsed. |
if (this.sitekeys && |
(!sitekey || this.sitekeys.indexOf(sitekey.toUpperCase()) < 0)) |
{ |
return false; |
} |
+ let {domains} = this; |
+ |
// If no domains are set the rule matches everywhere |
- if (!this.domains) |
+ if (!domains) |
return true; |
// If the document has no host name, match only if the filter |
// isn't restricted to specific domains |
if (!docDomain) |
- return this.domains.get(""); |
+ return domains.get(""); |
docDomain = docDomain.replace(/\.+$/, "").toLowerCase(); |
while (true) |
{ |
- let isDomainIncluded = this.domains.get(docDomain); |
+ let isDomainIncluded = domains.get(docDomain); |
if (typeof isDomainIncluded != "undefined") |
return isDomainIncluded; |
let nextDot = docDomain.indexOf("."); |
if (nextDot < 0) |
break; |
docDomain = docDomain.substr(nextDot + 1); |
} |
- return this.domains.get(""); |
+ return domains.get(""); |
}, |
/** |
* Checks whether this filter is active only on a domain and its subdomains. |
* @param {string} docDomain |
* @return {boolean} |
*/ |
isActiveOnlyOnDomain(docDomain) |
{ |
- if (!docDomain || !this.domains || this.domains.get("")) |
+ let {domains} = this; |
+ |
+ if (!docDomain || !domains || domains.get("")) |
return false; |
docDomain = docDomain.replace(/\.+$/, "").toLowerCase(); |
- for (let [domain, isIncluded] of this.domains) |
+ for (let [domain, isIncluded] of domains) |
{ |
if (isIncluded && domain != docDomain) |
{ |
if (domain.length <= docDomain.length) |
return false; |
if (!domain.endsWith("." + docDomain)) |
return false; |
@@ -535,18 +539,19 @@ |
}, |
/** |
* Checks whether this filter is generic or specific |
* @return {boolean} |
*/ |
isGeneric() |
{ |
- return !(this.sitekeys && this.sitekeys.length) && |
- (!this.domains || this.domains.get("")); |
+ let {sitekeys, domains} = this; |
Manish Jethani
2018/07/29 15:27:51
It didn't feel right to leave sitekeys behind here
|
+ |
+ return !(sitekeys && sitekeys.length) && (!domains || domains.get("")); |
}, |
/** |
* See Filter.serialize() |
* @inheritdoc |
*/ |
serialize(buffer) |
{ |