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

Unified Diff: lib/filterClasses.js

Issue 29874589: Issue 6927 - Expose pattern from RegExpFilter (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Rebase Created Sept. 4, 2018, 4:53 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 | lib/matcher.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
@@ -165,21 +165,16 @@
Filter.knownFilters = new Map();
/**
* Regular expression that content filters should match
* @type {RegExp}
*/
Filter.contentRegExp = /^([^/*|@"!]*?)#([@?$])?#(.+)$/;
/**
- * Regular expression that RegExp filters specified as RegExps should match
- * @type {RegExp}
- */
-Filter.regexpRegExp = /^(@@)?\/.*\/(?:\$~?[\w-]+(?:=[^,\s]+)?(?:,~?[\w-]+(?:=[^,\s]+)?)*)?$/;
-/**
* Regular expression that options on a RegExp filter should match
* @type {RegExp}
*/
Filter.optionsRegExp = /\$(~?[\w-]+(?:=[^,]*)?(?:,~?[\w-]+(?:=[^,]*)?)*)$/;
/**
* Regular expression that matches an invalid Content Security Policy
* @type {RegExp}
*/
@@ -683,17 +678,17 @@
// catch syntax errors
let regexp = new RegExp(regexpSource.substr(1, regexpSource.length - 2),
this.matchCase ? "" : "i");
Object.defineProperty(this, "regexp", {value: regexp});
}
else
{
// No need to convert this filter to regular expression yet, do it on demand
- this.regexpSource = regexpSource;
+ this.pattern = regexpSource;
}
}
exports.RegExpFilter = RegExpFilter;
RegExpFilter.prototype = extend(ActiveFilter, {
/**
* @see ActiveFilter.domainSourceIsLowerCase
*/
@@ -718,29 +713,28 @@
/**
* @see ActiveFilter.domainSeparator
*/
domainSeparator: "|",
/**
* Expression from which a regular expression should be generated -
* for delayed creation of the regexp property
- * @type {string}
+ * @type {?string}
*/
- regexpSource: null,
+ pattern: null,
/**
* Regular expression to be used when testing against this filter
* @type {RegExp}
*/
get regexp()
{
- let source = filterToRegExp(this.regexpSource, this.rewrite != null);
+ let source = filterToRegExp(this.pattern, this.rewrite != null);
let regexp = new RegExp(source, this.matchCase ? "" : "i");
Object.defineProperty(this, "regexp", {value: regexp});
- this.regexpSource = null;
return regexp;
},
/**
* Content types the filter applies to, combination of values from
* RegExpFilter.typeMap
* @type {number}
*/
contentType: 0x7FFFFFFF,
« no previous file with comments | « no previous file | lib/matcher.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld