(url: string, rules: URLRuleEntry[])
| 116 | // 检查单一网址是否符合 Exclusion 原则 |
| 117 | // 即匹配任何@exclude或所有@include/@match皆不匹配 |
| 118 | export 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 | |
| 141 | export const blackListSelfCheck = (blacklist: string[] | null | undefined) => { |
| 142 | blacklist = blacklist || []; |
no test coverage detected