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

Unified Diff: lib/matcher.js

Issue 29807560: Issue 6745 - Prefer strict equality operator (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created June 14, 2018, 4:11 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 | « lib/filterStorage.js ('k') | lib/notification.js » ('j') | 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
@@ -63,45 +63,45 @@
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 (typeof oldEntry === "undefined")
this.filterByKeyword.set(keyword, filter);
- else if (oldEntry.length == 1)
+ 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 (typeof keyword === "undefined")
return;
let list = this.filterByKeyword.get(keyword);
if (list.length <= 1)
this.filterByKeyword.delete(keyword);
else
{
let index = list.indexOf(filter);
if (index >= 0)
{
list.splice(index, 1);
- if (list.length == 1)
+ if (list.length === 1)
this.filterByKeyword.set(keyword, list[0]);
}
}
this.keywordByFilter.delete(filter);
},
/**
@@ -117,35 +117,35 @@
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] == "@")
+ if (text[0] === "@" && text[1] === "@")
text = text.substr(2);
let candidates = text.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;
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 = typeof filters !== "undefined" ? filters.length : 0;
if (count < resultCount ||
- (count == resultCount && candidate.length > resultLength))
+ (count === resultCount && candidate.length > resultLength))
{
result = candidate;
resultCount = count;
resultLength = candidate.length;
}
}
return result;
},
@@ -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 typeof keyword !== "undefined" ? 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 (typeof list === "undefined")
return null;
for (let i = 0; i < list.length; i++)
{
let filter = list[i];
if (specificOnly && filter.isGeneric() &&
!(filter instanceof WhitelistFilter))
continue;
@@ -407,17 +407,17 @@
* @inheritdoc
*/
matchesAny(location, typeMask, docDomain, thirdParty, sitekey, specificOnly)
{
let key = location + " " + typeMask + " " + docDomain + " " + thirdParty +
" " + sitekey + " " + specificOnly;
let result = this.resultCache.get(key);
- if (typeof result != "undefined")
+ if (typeof result !== "undefined")
return result;
result = this.matchesAnyInternal(location, typeMask, docDomain,
thirdParty, sitekey, specificOnly);
if (this.resultCache.size >= CombinedMatcher.maxCacheEntries)
this.resultCache.clear();
« no previous file with comments | « lib/filterStorage.js ('k') | lib/notification.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld