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

Unified Diff: lib/matcher.js

Issue 30002580: Noissue - Abstract hostname normalization (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Add tests Created Feb. 8, 2019, 7:26 p.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/filterClasses.js ('k') | test/domain.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/matcher.js
===================================================================
--- a/lib/matcher.js
+++ b/lib/matcher.js
@@ -18,17 +18,17 @@
"use strict";
/**
* @fileOverview Matcher class implementing matching addresses against
* a list of filters.
*/
const {RegExpFilter, WhitelistFilter} = require("./filterClasses");
-const {suffixes} = require("./domain");
+const {normalizeHostname, suffixes} = require("./domain");
/**
* Regular expression for matching a keyword in a filter.
* @type {RegExp}
*/
const keywordRegExp = /[^a-z0-9%*][a-z0-9%]{3,}(?=[^a-z0-9%*])/;
/**
@@ -494,27 +494,20 @@
return filtersByDomain;
collection.push(filtersByDomain);
}
return null;
}
- if (docDomain)
- {
- if (docDomain[docDomain.length - 1] == ".")
- docDomain = docDomain.replace(/\.+$/, "");
-
- docDomain = docDomain.toLowerCase();
- }
-
let excluded = new Set();
- for (let suffix of suffixes(docDomain || "", !specificOnly))
+ for (let suffix of suffixes(docDomain ? normalizeHostname(docDomain) : "",
+ !specificOnly))
{
let filters = filtersByDomain.get(suffix);
if (filters)
{
for (let [filter, include] of filters.entries())
{
if (!include)
{
« no previous file with comments | « lib/filterClasses.js ('k') | test/domain.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld