MCPcopy
hub / github.com/philc/vimium / getRule

Function getRule

background_scripts/exclusions.js:36–56  ·  view source on GitHub ↗
(url, rules)

Source from the content-addressed store, hash-verified

34// effect candidate new rules would have on the current tab. In this case, the candidate rules are
35// provided by the caller.
36function 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
58export function isEnabledForUrl(url) {
59 const rule = getRule(url);

Callers 1

isEnabledForUrlFunction · 0.85

Calls 2

getMethod · 0.80
filterMethod · 0.45

Tested by

no test coverage detected