(url, rules)
| 34 | // effect candidate new rules would have on the current tab. In this case, the candidate rules are |
| 35 | // provided by the caller. |
| 36 | function getRule(url, rules) { |
| 37 | if (rules == null) { |
| 38 | rules = Settings.get("exclusionRules"); |
| 39 | } |
| 40 | const matchingRules = rules.filter((r) => |
| 41 | r.pattern && (url.search(ExclusionRegexpCache.get(r.pattern)) >= 0) |
| 42 | ); |
| 43 | // An absolute exclusion rule (one with no passKeys) takes priority. |
| 44 | for (const rule of matchingRules) { |
| 45 | if (!rule.passKeys) return rule; |
| 46 | } |
| 47 | // Strip whitespace from all matching passKeys strings, and join them together. |
| 48 | const passKeys = matchingRules.map((r) => r.passKeys.split(/\s+/).join("")).join(""); |
| 49 | // TODO(philc): Remove this commented out code. |
| 50 | // passKeys = (rule.passKeys.split(/\s+/).join "" for rule in matchingRules).join "" |
| 51 | if (matchingRules.length > 0) { |
| 52 | return { passKeys: Utils.distinctCharacters(passKeys) }; |
| 53 | } else { |
| 54 | return null; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | export function isEnabledForUrl(url) { |
| 59 | const rule = getRule(url); |
no test coverage detected