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

Function isValidPattern

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

Source from the content-addressed store, hash-verified

103};
104
105export const isValidPattern = (pattern: string): boolean => {
106 if (pattern.length === 0) return false;
107 if (pattern === "*") return true;
108 if (pattern.startsWith(".") || pattern.endsWith(".")) return false;
109 if (pattern.includes("..")) return false;
110 if (pattern.startsWith("*")) return false;
111 const segments = pattern.split(".");
112 for (let i = 0; i < segments.length; i++) {
113 const seg = segments[i]!;
114 if (seg.length === 0) return false;
115 // A `*` segment must be the WHOLE segment — no partial wildcards (`me*`).
116 // A `*` is valid mid-pattern (one segment) or trailing (subtree).
117 if (seg.includes("*") && seg !== "*") return false;
118 }
119 return true;
120};
121
122// ---------------------------------------------------------------------------
123// Resolution — each owner contributes its first matching rule by local

Callers 5

policiesCreateFunction · 0.90
policiesUpdateFunction · 0.90
policies.test.tsFile · 0.90
validatePolicyPatternFunction · 0.90
AddPolicyFormFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected