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

Unified Diff: test/filterClasses.js

Issue 29791555: Issue 6727 - Use string rather than map for single-domain filters (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Fix ESLint error Created June 6, 2018, 11:59 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/filterClasses.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/filterClasses.js
===================================================================
--- a/test/filterClasses.js
+++ b/test/filterClasses.js
@@ -66,20 +66,27 @@
{
result.push("disabled=" + filter.disabled);
result.push("lastHit=" + filter.lastHit);
result.push("hitCount=" + filter.hitCount);
let domains = [];
if (filter.domains)
{
- for (let [domain, isIncluded] of filter.domains)
+ if (typeof filter.domains == "string")
+ {
+ domains.push(filter.domains);
+ }
+ else
{
- if (domain != "")
- domains.push(isIncluded ? domain : "~" + domain);
+ for (let [domain, isIncluded] of filter.domains)
+ {
+ if (domain != "")
+ domains.push(isIncluded ? domain : "~" + domain);
+ }
}
}
result.push("domains=" + domains.sort().join("|"));
if (filter instanceof RegExpFilter)
{
result.push("regexp=" + filter.regexp.source);
result.push("contentType=" + filter.contentType);
@@ -103,18 +110,20 @@
{
if (filter instanceof ElemHideFilter)
result.push("type=elemhide");
else if (filter instanceof ElemHideException)
result.push("type=elemhideexception");
else if (filter instanceof ElemHideEmulationFilter)
result.push("type=elemhideemulation");
+ let filterDomains = typeof filter.domains == "string" ?
+ [[filter.domains, true]] : filter.domains;
result.push("selectorDomains=" +
- [...filter.domains || []]
+ [...filterDomains || []]
.filter(([domain, isIncluded]) => isIncluded)
.map(([domain]) => domain.toLowerCase()));
result.push("selector=" + filter.selector);
}
}
return result;
}
« no previous file with comments | « lib/filterClasses.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld