Index: lib/matcher.js |
=================================================================== |
--- a/lib/matcher.js |
+++ b/lib/matcher.js |
@@ -362,34 +362,44 @@ |
matchesAnyInternal(location, typeMask, docDomain, thirdParty, sitekey, |
specificOnly) |
{ |
let candidates = location.toLowerCase().match(/[a-z0-9%]{3,}/g); |
if (candidates === null) |
candidates = []; |
candidates.push(""); |
+ let whitelistHit = null; |
let blacklistHit = null; |
+ |
for (let i = 0, l = candidates.length; i < l; i++) |
Sebastian Noack
2018/09/30 13:39:23
Any reason to not use for..of here?
Manish Jethani
2018/10/21 13:57:03
for..of is quite a bit slower in this case.
|
{ |
let substr = candidates[i]; |
- let result = this.whitelist._checkEntryMatch( |
- substr, location, typeMask, docDomain, thirdParty, sitekey |
+ blacklistHit = this.blacklist._checkEntryMatch( |
+ substr, location, typeMask, docDomain, thirdParty, sitekey, |
+ specificOnly |
); |
- if (result) |
- return result; |
- if (blacklistHit === null) |
+ if (blacklistHit) |
+ break; |
+ } |
+ |
+ if (blacklistHit) |
+ { |
+ for (let i = 0, l = candidates.length; i < l; i++) |
{ |
- blacklistHit = this.blacklist._checkEntryMatch( |
- substr, location, typeMask, docDomain, thirdParty, sitekey, |
- specificOnly |
+ let substr = candidates[i]; |
+ whitelistHit = this.whitelist._checkEntryMatch( |
+ substr, location, typeMask, docDomain, thirdParty, sitekey |
); |
+ if (whitelistHit) |
+ break; |
} |
} |
- return blacklistHit; |
+ |
+ return whitelistHit || blacklistHit; |
} |
/** |
* @see Matcher#matchesAny |
* @inheritdoc |
*/ |
matchesAny(location, typeMask, docDomain, thirdParty, sitekey, specificOnly) |
{ |