matchesRule function ✓ 100.0%

Last updated: 2026-03-02T15:32:34.984Z

Metrics

LOC: 11 Complexity: 6 Params: 2 Coverage: 100.0% (6/6 lines, 74x executed)

Signature

matchesRule(normalized: string, rule: KeywordRule): : boolean

Source Code

function matchesRule(normalized: string, rule: KeywordRule): boolean {
  for (const pattern of rule.patterns) {
    if (rule.wholeWord) {
      const re = new RegExp(`(?<![a-z0-9])${escapeRegex(pattern)}(?![a-z0-9])`);
      if (re.test(normalized)) return true;
    } else {
      if (normalized.includes(pattern)) return true;
    }
  }
  return false;
}

Dependencies (Outgoing)

graph LR matchesRule["matchesRule"] escapeRegex["escapeRegex"] matchesRule -->|calls| escapeRegex style matchesRule fill:#dbeafe,stroke:#2563eb,stroke-width:2px click matchesRule "1a959a10048b5e94.html" click escapeRegex "f946f576c045998d.html"
TargetType
escapeRegex calls
normalized dynamic_call

Impact (Incoming)

graph LR matchesRule["matchesRule"] detect["detect"] detect -->|calls| matchesRule style matchesRule fill:#dbeafe,stroke:#2563eb,stroke-width:2px click matchesRule "1a959a10048b5e94.html" click detect "3ad5e2f09986771f.html"
SourceType
detect calls