MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / normalizeRelativeRulePath

Function normalizeRelativeRulePath

src/services/rules/rules.ts:339–355  ·  view source on GitHub ↗
(relativePath: string)

Source from the content-addressed store, hash-verified

337}
338
339function normalizeRelativeRulePath(relativePath: string): string {
340 const trimmed = relativePath.trim()
341
342 if (!trimmed) {
343 throw new Error("Rule path is required")
344 }
345
346 if (path.isAbsolute(trimmed) || trimmed.split(/[\\/]+/).includes("..")) {
347 throw new Error("Invalid rule path")
348 }
349
350 if (!shouldIncludeRuleFile(trimmed)) {
351 throw new Error("Invalid rule file")
352 }
353
354 return path.normalize(trimmed)
355}
356
357function validateModeSlug(modeSlug: string): string {
358 if (!/^[a-zA-Z0-9_-]+$/.test(modeSlug)) {

Callers 1

resolveRuleFileFunction · 0.85

Calls 1

shouldIncludeRuleFileFunction · 0.70

Tested by

no test coverage detected