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

Function isUrlExcluded

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

Source from the content-addressed store, hash-verified

116// 检查单一网址是否符合 Exclusion 原则
117// 即匹配任何@exclude或所有@include/@match皆不匹配
118export function isUrlExcluded(url: string, rules: URLRuleEntry[]): boolean {
119 let anyInclusionRule = false;
120 let anyExclusionRule = false;
121 for (const rule of rules) {
122 if (rule.ruleType & RuleTypeBit.INCLUSION) {
123 // include
124 if (!anyInclusionRule && isUrlMatch(url, rule)) {
125 // 符合 inclusion
126 anyInclusionRule = true;
127 }
128 } else {
129 // exclude
130 if (!isUrlMatch(url, rule)) {
131 // 符合 exclusion
132 anyExclusionRule = true;
133 break;
134 }
135 }
136 }
137 // true 条件: ( All @include/@match = false ) OR ( Any @exclude = true )
138 return !anyInclusionRule || anyExclusionRule;
139}
140
141export const blackListSelfCheck = (blacklist: string[] | null | undefined) => {
142 blacklist = blacklist || [];

Callers 2

match.test.tsFile · 0.90

Calls 1

isUrlMatchFunction · 0.90

Tested by

no test coverage detected