MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / patternSpecificity

Function patternSpecificity

packages/core/sdk/src/policies.ts:152–159  ·  view source on GitHub ↗
(pattern: string)

Source from the content-addressed store, hash-verified

150// `vercel.dns` → 5 (2 literal segments, exact — beats same-prefix wildcard)
151// `vercel.dns.create` → 7 (3 literal segments, exact)
152export const patternSpecificity = (pattern: string): number => {
153 if (pattern === "*") return 0;
154 if (pattern.endsWith(".*")) {
155 const prefix = pattern.slice(0, -2);
156 return prefix.split(".").length * 2;
157 }
158 return pattern.split(".").length * 2 + 1;
159};
160
161/**
162 * Position key for a new rule among an owner's existing rules, placed just

Callers 1

positionForNewPatternFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected