Index: lib/matcher.js |
=================================================================== |
--- a/lib/matcher.js |
+++ b/lib/matcher.js |
@@ -63,33 +63,33 @@ |
add(filter) |
{ |
if (this.keywordByFilter.has(filter)) |
return; |
// Look for a suitable keyword |
let keyword = this.findKeyword(filter); |
let oldEntry = this.filterByKeyword.get(keyword); |
- if (typeof oldEntry == "undefined") |
+ if (!oldEntry) |
this.filterByKeyword.set(keyword, filter); |
else if (oldEntry.length == 1) |
this.filterByKeyword.set(keyword, [oldEntry, filter]); |
else |
oldEntry.push(filter); |
this.keywordByFilter.set(filter, keyword); |
}, |
/** |
* Removes a filter from the matcher |
* @param {RegExpFilter} filter |
*/ |
remove(filter) |
{ |
let keyword = this.keywordByFilter.get(filter); |
- if (typeof keyword == "undefined") |
+ if (keyword == null) |
Manish Jethani
2018/06/12 04:50:27
keyword can be an empty string, so we must check a
|
return; |
let list = this.filterByKeyword.get(keyword); |
if (list.length <= 1) |
this.filterByKeyword.delete(keyword); |
else |
{ |
let index = list.indexOf(filter); |
@@ -133,17 +133,17 @@ |
let hash = this.filterByKeyword; |
let resultCount = 0xFFFFFF; |
let resultLength = 0; |
for (let i = 0, l = candidates.length; i < l; i++) |
{ |
let candidate = candidates[i].substr(1); |
let filters = hash.get(candidate); |
- let count = typeof filters != "undefined" ? filters.length : 0; |
+ let count = filters ? filters.length : 0; |
if (count < resultCount || |
(count == resultCount && candidate.length > resultLength)) |
{ |
result = candidate; |
resultCount = count; |
resultLength = candidate.length; |
} |
} |
@@ -163,17 +163,17 @@ |
/** |
* Returns the keyword used for a filter, null for unknown filters. |
* @param {RegExpFilter} filter |
* @return {?string} |
*/ |
getKeywordForFilter(filter) |
{ |
let keyword = this.keywordByFilter.get(filter); |
- return typeof keyword != "undefined" ? keyword : null; |
+ return keyword != null ? keyword : null; |
}, |
/** |
* Checks whether the entries for a particular keyword match a URL |
* @param {string} keyword |
* @param {string} location |
* @param {number} typeMask |
* @param {string} docDomain |
@@ -181,17 +181,17 @@ |
* @param {string} sitekey |
* @param {boolean} specificOnly |
* @return {?Filter} |
*/ |
_checkEntryMatch(keyword, location, typeMask, docDomain, thirdParty, sitekey, |
specificOnly) |
{ |
let list = this.filterByKeyword.get(keyword); |
- if (typeof list == "undefined") |
+ if (!list) |
return null; |
for (let i = 0; i < list.length; i++) |
{ |
let filter = list[i]; |
if (specificOnly && filter.isGeneric() && |
!(filter instanceof WhitelistFilter)) |
continue; |