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

Unified Diff: lib/filterClasses.js

Issue 29361640: Issue 4593 - Support regular expressions for CSS property matching (Closed) Base URL: https://bitbucket.org/fhd/adblockpluscore
Patch Set: Created Nov. 3, 2016, 11:40 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 | « no previous file | test/filterClasses.js » ('j') | 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
@@ -1037,13 +1037,18 @@
get regexpString()
{
// Despite this property being cached, the getter is called
// several times on Safari, due to WebKit bug 132872
let prop = Object.getOwnPropertyDescriptor(this, "regexpString");
if (prop)
return prop.value;
- let regexp = Filter.toRegExp(this.regexpSource);
+ let regexp;
+ if (this.regexpSource.charAt(0) == "/" &&
kzar 2016/11/03 12:18:16 Nit: How about using startsWith and endsWith inste
Felix Dahlke 2016/11/03 13:47:51 Wouldn't work on Safari <9, would it? Maybe this i
kzar 2016/11/03 16:03:19 Right, we wouldn't be able to update the adblockpl
Felix Dahlke 2016/11/03 19:08:02 Alright, seems safe to break Safari <9 then - done
+ this.regexpSource.slice(-1) == "/")
+ regexp = this.regexpSource.slice(1, -1);
kzar 2016/11/03 12:18:16 What about flags, for example for case-insensitive
Felix Dahlke 2016/11/03 13:47:51 Hm, good point. How I see it, `i` is actually the
kzar 2016/11/03 16:03:19 Yea, I think you're right there. I thought perhaps
Felix Dahlke 2016/11/03 19:08:02 I dug a bit deeper and while I was apparently righ
kzar 2016/11/04 10:06:56 I would prefer to switch to case insensitive match
Felix Dahlke 2016/11/04 13:43:56 I know it'd be a simple change and I agree we shou
kzar 2016/11/04 14:29:50 It's not really an unrelated change IMO, since lik
Felix Dahlke 2016/11/04 16:11:44 Well, it's mainly for consistency with how our oth
kzar 2016/11/04 16:18:27 Yea they do, I checked that.
Felix Dahlke 2016/11/04 16:51:16 URL matching is _always_ case insensitive, whether
+ else
+ regexp = Filter.toRegExp(this.regexpSource);
Object.defineProperty(this, "regexpString", {value: regexp});
return regexp;
}
});
« no previous file with comments | « no previous file | test/filterClasses.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld