Move pattern matching into separate module
Background
Pattern matching is a fundamental part of ad blocking. In fact, Adblock Plus (EasyList) has its own syntax for specifying URL patterns. Previously we used to convert all patterns into RegExp
objects. This was simple but not very efficient. Now we have switched to more sophisticated forms of matching, using combinations of literal strings and regular expressions (see issues 7052, 7209, and 7321) and combining multiple patterns into a single regular expression (see issue 7444 and #28 (closed)).
All of the code for pattern matching is currently scattered across multiple files. It would be nice to combine it all into a single coherent patterns
module.
What to change
Move pattern matching code from lib/filterClasses.js
and lib/matcher.js
into a new lib/patterns.js
file.
Testing notes
This is a refactoring change and is not expected to affect the behaviour of the public interface.
Integration notes
URLFilter.pattern
and URLFilter.regexp
are deprecated (this also affects URLFilter
's child classes, BlockingFilter
and AllowingFilter
). The equivalent of these properties is still available through URLFilter.urlPattern.pattern
and URLFilter.urlPattern.regexp
.
See the Pattern
class for more available pattern fields, such as Pattern.isLiteralPattern
, Pattern.keywordCandidates
and Pattern.regexpSource
.