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

Unified Diff: lib/abp2blocklist.js

Issue 29443587: Noissue - Do not add subdomain wildcard if subdomain excluded (Closed) Base URL: https://hg.adblockplus.org/abp2blocklist
Patch Set: Created May 20, 2017, 11:50 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/abp2blocklist.js
===================================================================
--- a/lib/abp2blocklist.js
+++ b/lib/abp2blocklist.js
@@ -263,19 +263,35 @@
if (trigger["resource-type"].length == 0)
return;
}
if (filter.thirdParty != null)
trigger["load-type"] = [filter.thirdParty ? "third-party" : "first-party"];
if (included.length > 0)
- trigger["if-domain"] = included.map(name => "*" + name);
+ {
+ trigger["if-domain"] = included.map(name =>
+ {
+ if (filter instanceof filterClasses.WhitelistFilter)
+ return "*" + name;
+
+ // If this is not a whitelisting filter, add the subdomain wildcard only
+ // if no subdomains have been excluded.
+ let regExp = new RegExp("\." + escapeRegExp(name) + "$");
+ if (!excluded.some(name => regExp.test(name)))
+ return "*" + name;
+
+ return name;
+ });
+ }
else if (excluded.length > 0)
+ {
trigger["unless-domain"] = excluded.map(name => "*" + name);
+ }
rules.push({trigger: trigger, action: {type: action}});
}
function hasNonASCI(obj)
{
if (typeof obj == "string")
{
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld