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; |