aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts
diff options
context:
space:
mode:
Diffstat (limited to 'background_scripts')
-rw-r--r--background_scripts/exclusions.coffee8
1 files changed, 5 insertions, 3 deletions
diff --git a/background_scripts/exclusions.coffee b/background_scripts/exclusions.coffee
index 62647bd8..55ced3ef 100644
--- a/background_scripts/exclusions.coffee
+++ b/background_scripts/exclusions.coffee
@@ -23,15 +23,17 @@ root.Exclusions = Exclusions =
rules: Settings.get("exclusionRules")
- # Merge the matching rules for URL, or null. If rules are provided, match against those.
+ # Merge the matching rules for URL, or null. In the normal case, we use the configured @rules; hence, this
+ # is the default. However, when called from the page popup, we are testing what effect candidate new rules
+ # would have on the current tab. In this case, the candidate rules are provided by the caller.
getRule: (url, rules=@rules) ->
matches = (rule for rule in rules when rule.pattern and 0 <= url.search(RegexpCache.get(rule.pattern)))
# An absolute exclusion rule (with no passKeys) takes priority.
for rule in matches
return rule unless rule.passKeys
- if matches.length
+ if 0 < matches.length
pattern: (rule.pattern for rule in matches).join " | " # Not used; for debugging only.
- passKeys: Utils.uniqueCharacters (rule.passKeys for rule in matches).join ""
+ passKeys: Utils.distinctCharacters (rule.passKeys for rule in matches).join ""
else
null