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") |
{ |