MCPcopy Create free account
hub / github.com/scriptscat/scriptcat / isUrlIncluded

Function isUrlIncluded

src/pkg/utils/match.ts:93–114  ·  view source on GitHub ↗
(url: string, rules: URLRuleEntry[])

Source from the content-addressed store, hash-verified

91// 检查单一网址是否符合 Inclusion 原则
92// 即匹配任一@include/@match且不匹配任何@exclude
93export function isUrlIncluded(url: string, rules: URLRuleEntry[]): boolean {
94 let anyInclusionRule = false;
95 let anyExclusionRule = false;
96 for (const rule of rules) {
97 if (rule.ruleType & RuleTypeBit.INCLUSION) {
98 // include
99 if (!anyInclusionRule && isUrlMatch(url, rule)) {
100 // 符合 inclusion
101 anyInclusionRule = true;
102 }
103 } else {
104 // exclude
105 if (!isUrlMatch(url, rule)) {
106 // 符合 exclusion
107 anyExclusionRule = true;
108 break;
109 }
110 }
111 }
112 // true 条件: ( Any @include/@match = true ) AND ( All @exclude = false )
113 return anyInclusionRule && !anyExclusionRule;
114}
115
116// 检查单一网址是否符合 Exclusion 原则
117// 即匹配任何@exclude或所有@include/@match皆不匹配

Callers 2

match.test.tsFile · 0.90
urlMatchMethod · 0.85

Calls 1

isUrlMatchFunction · 0.90

Tested by

no test coverage detected