MCPcopy Index your code
hub / github.com/Dimillian/CodexMonitor / normalizeCodexArgsInput

Function normalizeCodexArgsInput

src/utils/codexArgsInput.ts:17–48  ·  view source on GitHub ↗
(value: string | null | undefined)

Source from the content-addressed store, hash-verified

15}
16
17export function normalizeCodexArgsInput(value: string | null | undefined): string | null {
18 const raw = (value ?? "").trim();
19 if (!raw) {
20 return null;
21 }
22
23 let normalized = raw
24 .replace(NBSP_PATTERN, " ")
25 .replace(SMART_DOUBLE_QUOTES_PATTERN, "\"")
26 .replace(SMART_SINGLE_QUOTES_PATTERN, "'")
27 .trim();
28
29 normalized = stripWrappingQuotes(normalized).trim();
30
31 normalized = normalized.replace(
32 DASH_LIKE_TOKEN_PREFIX_PATTERN,
33 (_match, prefix: string, token: string) => {
34 const equalsIndex = token.indexOf("=");
35 const flagToken = equalsIndex >= 0 ? token.slice(0, equalsIndex) : token;
36 const suffix = equalsIndex >= 0 ? token.slice(equalsIndex) : "";
37
38 if (/^[A-Za-z][A-Za-z0-9-]*$/.test(flagToken)) {
39 return `${prefix}${flagToken.length === 1 ? "-" : "--"}${flagToken}${suffix}`;
40 }
41 return `${prefix}-${token}`;
42 },
43 );
44
45 normalized = normalized.replace(DASH_LIKE_PATTERN, "-").trim();
46
47 return normalized.length > 0 ? normalized : null;
48}

Callers 6

useSettingsCodexSectionFunction · 0.90
MainAppFunction · 0.90
normalizeCodexArgsFunction · 0.90
parseCodexArgsProfileFunction · 0.90

Calls 1

stripWrappingQuotesFunction · 0.70

Tested by

no test coverage detected