aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts/exclusions.coffee
diff options
context:
space:
mode:
Diffstat (limited to 'background_scripts/exclusions.coffee')
-rw-r--r--background_scripts/exclusions.coffee13
1 files changed, 10 insertions, 3 deletions
diff --git a/background_scripts/exclusions.coffee b/background_scripts/exclusions.coffee
index 55ced3ef..21342d61 100644
--- a/background_scripts/exclusions.coffee
+++ b/background_scripts/exclusions.coffee
@@ -2,6 +2,7 @@ root = exports ? window
RegexpCache =
cache: {}
+ clear: -> @cache = {}
get: (pattern) ->
if regexp = @cache[pattern]
regexp
@@ -31,9 +32,11 @@ root.Exclusions = Exclusions =
# An absolute exclusion rule (with no passKeys) takes priority.
for rule in matches
return rule unless rule.passKeys
+ # Strip whitespace from all matching passKeys strings, and join them together.
+ passKeys = (rule.passKeys.split(/\s+/).join "" for rule in matches).join ""
if 0 < matches.length
pattern: (rule.pattern for rule in matches).join " | " # Not used; for debugging only.
- passKeys: Utils.distinctCharacters (rule.passKeys for rule in matches).join ""
+ passKeys: Utils.distinctCharacters passKeys
else
null
@@ -42,8 +45,8 @@ root.Exclusions = Exclusions =
@rules = rules.filter (rule) -> rule and rule.pattern
Settings.set("exclusionRules", @rules)
- postUpdateHook: (rules) ->
- @rules = rules
+ postUpdateHook: (@rules) ->
+ RegexpCache.clear()
# Development and debug only.
# Enable this (temporarily) to restore legacy exclusion rules from backup.
@@ -70,3 +73,7 @@ if not Settings.has("exclusionRules") and Settings.has("excludedUrls")
# We'll keep a backup of the "excludedUrls" setting, just in case.
Settings.set("excludedUrlsBackup", Settings.get("excludedUrls")) if not Settings.has("excludedUrlsBackup")
Settings.clear("excludedUrls")
+
+# Register postUpdateHook for exclusionRules setting.
+Settings.postUpdateHooks["exclusionRules"] = (value) ->
+ Exclusions.postUpdateHook value