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

Unified Diff: lib/filterClasses.js

Issue 29999569: Noissue - Use suffixes function (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Remove misleading comment Created Feb. 6, 2019, 1:15 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/elemHide.js ('k') | no next file » | 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
@@ -16,19 +16,21 @@
*/
"use strict";
/**
* @fileOverview Definition of Filter class and its subclasses.
*/
-const {filterNotifier} = require("./filterNotifier");
const {extend} = require("./coreUtils");
const {filterToRegExp} = require("./common");
+const {suffixes} = require("./domain");
+const {filterNotifier} = require("./filterNotifier");
+
const resources = require("../data/resources.json");
/**
* Map of internal resources for URL rewriting.
* @type {Map.<string,string>}
*/
let resourceMap = new Map(
Object.keys(resources).map(key => [key, resources[key]])
@@ -604,27 +606,23 @@
if (!docDomain)
return domains.get("");
if (docDomain[docDomain.length - 1] == ".")
docDomain = docDomain.replace(/\.+$/, "");
docDomain = docDomain.toLowerCase();
- while (true)
+ for (docDomain of suffixes(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 domains.get("");
},
/**
* Checks whether this filter is active only on a domain and its subdomains.
* @param {string} docDomain
* @return {boolean}
*/
« no previous file with comments | « lib/elemHide.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld