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

Unified Diff: lib/matcher.js

Issue 29874589: Issue 6927 - Expose pattern from RegExpFilter (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Sept. 4, 2018, 2:41 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
« lib/filterClasses.js ('K') | « lib/filterClasses.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/matcher.js
===================================================================
--- a/lib/matcher.js
+++ b/lib/matcher.js
@@ -17,17 +17,17 @@
"use strict";
/**
* @fileOverview Matcher class implementing matching addresses against
* a list of filters.
*/
-const {Filter, WhitelistFilter} = require("./filterClasses");
+const {WhitelistFilter} = require("./filterClasses");
/**
* Blacklist/whitelist filter matching
* @constructor
*/
function Matcher()
{
this.clear();
@@ -107,30 +107,21 @@
/**
* Chooses a keyword to be associated with the filter
* @param {Filter} filter
* @return {string} keyword or an empty string if no keyword could be found
*/
findKeyword(filter)
{
let result = "";
- let {text} = filter;
- if (Filter.regexpRegExp.test(text))
Manish Jethani 2018/09/04 14:50:47 All of this regular expression matching is redunda
+ let {pattern} = filter;
+ if (pattern == null)
return result;
- // Remove options
- let match = Filter.optionsRegExp.exec(text);
- if (match)
- text = match.input.substr(0, match.index);
-
- // Remove whitelist marker
- if (text[0] == "@" && text[1] == "@")
- text = text.substr(2);
-
- let candidates = text.toLowerCase().match(
+ let candidates = pattern.toLowerCase().match(
/[^a-z0-9%*][a-z0-9%]{3,}(?=[^a-z0-9%*])/g
);
if (!candidates)
return result;
let hash = this.filterByKeyword;
let resultCount = 0xFFFFFF;
let resultLength = 0;
« lib/filterClasses.js ('K') | « lib/filterClasses.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld