diff options
| author | Stephen Blott | 2014-12-21 06:39:46 +0000 | 
|---|---|---|
| committer | Stephen Blott | 2014-12-21 06:39:46 +0000 | 
| commit | 681bc13783d1f1b8579f810dbbc68174a84c1a10 (patch) | |
| tree | 0f4d5957e853eb23e250326b58e5b322fea77585 /background_scripts/exclusions.coffee | |
| parent | e2fe06c25ad0d478a602f77d3ea052ac0e886233 (diff) | |
| download | vimium-681bc13783d1f1b8579f810dbbc68174a84c1a10.tar.bz2 | |
Exclusion; multi-rule matching.
Diffstat (limited to 'background_scripts/exclusions.coffee')
| -rw-r--r-- | background_scripts/exclusions.coffee | 24 | 
1 files changed, 7 insertions, 17 deletions
diff --git a/background_scripts/exclusions.coffee b/background_scripts/exclusions.coffee index fd74e7da..db86e583 100644 --- a/background_scripts/exclusions.coffee +++ b/background_scripts/exclusions.coffee @@ -23,11 +23,14 @@ root.Exclusions = Exclusions =    rules: Settings.get("exclusionRules") -  # Return the first exclusion rule matching the URL, or null. +  # Merge the matching rules for URL, or null.    getRule: (url) -> -    for rule in @rules -      return rule if url.match(RegexpCache.get(rule.pattern)) -    return null +    matching = (rule for rule in @rules when url.match(RegexpCache.get(rule.pattern))) +    if matching.length +      pattern: (rule.pattern for rule in matching).join " | " # Not used; for documentation/debugging only. +      passKeys: (rule.passKeys for rule in matching).join "" +    else +      null    setRules: (rules) ->      # Callers map a rule to null to have it deleted, and rules without a pattern are useless. @@ -37,19 +40,6 @@ root.Exclusions = Exclusions =    postUpdateHook: (rules) ->      @rules = rules -  # Update an existing rule or add a new rule. -  updateOrAdd: (newRule) -> -    seen = false -    @rules.push(newRule) -    @setRules @rules.map (rule) -> -      if rule.pattern == newRule.pattern -        if seen then null else seen = newRule -      else -        rule - -  remove: (pattern) -> -    @setRules(@rules.filter((rule) -> rule and rule.pattern != pattern)) -  # Development and debug only.  # Enable this (temporarily) to restore legacy exclusion rules from backup.  if false and Settings.has("excludedUrlsBackup")  | 
