MCPcopy Create free account
hub / github.com/pingdotgg/t3code / normalizeScriptId

Function normalizeScriptId

apps/web/src/projectScripts.ts:10–23  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

8const isScriptRunCommand = Schema.is(SCRIPT_RUN_COMMAND_PATTERN);
9
10function normalizeScriptId(value: string): string {
11 const cleaned = value
12 .trim()
13 .toLowerCase()
14 .replace(/[^a-z0-9]+/g, "-")
15 .replace(/^-+|-+$/g, "");
16 if (cleaned.length === 0) {
17 return "script";
18 }
19 if (cleaned.length <= MAX_SCRIPT_ID_LENGTH) {
20 return cleaned;
21 }
22 return cleaned.slice(0, MAX_SCRIPT_ID_LENGTH).replace(/-+$/g, "") || "script";
23}
24
25export const commandForProjectScript = (scriptId: string): KeybindingCommand =>
26 SCRIPT_RUN_COMMAND_PATTERN.make(`script.${scriptId}.run`);

Callers 1

nextProjectScriptIdFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected