MCPcopy Create free account
hub / github.com/backnotprop/plannotator / sanitizeTag

Function sanitizeTag

packages/shared/project.ts:15–28  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

13 * - trim to reasonable length
14 */
15export function sanitizeTag(name: string): string | null {
16 if (!name || typeof name !== "string") return null;
17
18 const sanitized = name
19 .toLowerCase()
20 .trim()
21 .replace(/[\s_]+/g, "-") // spaces/underscores -> hyphens
22 .replace(/[^a-z0-9-]/g, "") // remove special chars
23 .replace(/-+/g, "-") // collapse multiple hyphens
24 .replace(/^-|-$/g, "") // trim leading/trailing hyphens
25 .slice(0, 30); // max 30 chars
26
27 return sanitized.length >= 2 ? sanitized : null;
28}
29
30/**
31 * Extract repo name from a git root path

Callers 7

generateSlugFunction · 0.90
project.test.tsFile · 0.90
executeFunction · 0.90
extractRepoNameFunction · 0.85
extractDirNameFunction · 0.85
detectProjectNameFunction · 0.85
detectProjectNameSyncFunction · 0.85

Calls 1

replaceMethod · 0.80

Tested by

no test coverage detected