Index: lib/contentBlockerLists.js |
diff --git a/lib/contentBlockerLists.js b/lib/contentBlockerLists.js |
index 95b94fc16eda818c6e2f692c0cd5b8f789b0cc32..a7c2e32847501c2d656c3c2ff4482e9c9585a7e2 100644 |
--- a/lib/contentBlockerLists.js |
+++ b/lib/contentBlockerLists.js |
@@ -172,12 +172,32 @@ function addDomainPrefix(domains) |
return result; |
} |
+function caseSensitive(filter) |
Sebastian Noack
2016/02/21 21:42:30
It probably makes sense to integrate the logic her
kzar
2016/02/24 15:43:29
Done.
|
+{ |
+ if (filter.matchCase) |
+ return true; |
+ |
+ if (!(filter.text.startsWith("||") || filter.text.startsWith("://"))) |
Sebastian Noack
2016/02/21 21:42:30
Filters usually don't start with "://". But filter
kzar
2016/02/24 15:43:29
Done.
|
+ return false; |
+ |
+ let offset = filter.text.startsWith("||") ? 2 : 3; |
+ let boundary = filter.text.substr(offset).search(/\/\?\*\^/); |
Sebastian Noack
2016/02/21 21:42:30
This regular expression would only match a seqeunc
kzar
2016/02/24 15:43:29
(Yep, forgot the brackets.)
|
+ |
+ if (boundary == -1) |
+ return true; |
+ |
+ return filter.text.substr(offset + boundary + 1).search(/[a-zA-Z]/) == -1; |
+} |
+ |
function convertFilter(filter, action, withResourceTypes) |
{ |
let trigger = {"url-filter": getRegExpSource(filter)}; |
let included = []; |
let excluded = []; |
+ if (caseSensitive(filter)) |
+ trigger["url-filter-is-case-sensitive"] = true; |
+ |
parseDomains(filter.domains, included, excluded); |
if (withResourceTypes) |
@@ -362,7 +382,8 @@ exports.convertFilters = function(filters) |
selector = convertIDSelectorsToAttributeSelectors(selector); |
addRule({ |
- trigger: {"url-filter": matchDomain}, |
+ trigger: {"url-filter": matchDomain, |
Sebastian Noack
2016/02/21 21:42:30
Same for element hiding filters; we have to make s
kzar
2016/02/24 15:43:29
Done.
|
+ "url-filter-is-case-sensitive": true}, |
action: {type: "css-display-none", |
selector: selector} |
}); |