Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/filterClasses.js

Issue 30002580: Noissue - Abstract hostname normalization (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Feb. 8, 2019, 10:26 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/elemHide.js ('k') | lib/matcher.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « lib/elemHide.js ('k') | lib/matcher.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld