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

Function isValidPattern

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

Source from the content-addressed store, hash-verified

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