Index: lib/filterClasses.js |
=================================================================== |
--- a/lib/filterClasses.js |
+++ b/lib/filterClasses.js |
@@ -18,17 +18,17 @@ |
"use strict"; |
/** |
* @fileOverview Definition of Filter class and its subclasses. |
*/ |
const {extend} = require("./coreUtils"); |
const {filterToRegExp} = require("./common"); |
-const {suffixes} = require("./domain"); |
+const {normalizeHostname, suffixes} = require("./domain"); |
const {filterNotifier} = require("./filterNotifier"); |
const resources = require("../data/resources.json"); |
/** |
* Map of internal resources for URL rewriting. |
* @type {Map.<string,string>} |
*/ |
@@ -601,22 +601,17 @@ |
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 domains.get(""); |
- if (docDomain[docDomain.length - 1] == ".") |
- docDomain = docDomain.replace(/\.+$/, ""); |
- |
- docDomain = docDomain.toLowerCase(); |
- |
- for (docDomain of suffixes(docDomain)) |
+ for (docDomain of suffixes(normalizeHostname(docDomain))) |
{ |
let isDomainIncluded = domains.get(docDomain); |
if (typeof isDomainIncluded != "undefined") |
return isDomainIncluded; |
} |
return domains.get(""); |
}, |
@@ -628,20 +623,17 @@ |
*/ |
isActiveOnlyOnDomain(docDomain) |
{ |
let {domains} = this; |
if (!docDomain || !domains || domains.get("")) |
return false; |
- if (docDomain[docDomain.length - 1] == ".") |
- docDomain = docDomain.replace(/\.+$/, ""); |
- |
- docDomain = docDomain.toLowerCase(); |
+ docDomain = normalizeHostname(docDomain); |
for (let [domain, isIncluded] of domains) |
{ |
if (isIncluded && domain != docDomain) |
{ |
if (domain.length <= docDomain.length) |
return false; |