MCPcopy Create free account
hub / github.com/OpenCoworkAI/open-codesign / parseLegacyStringLiteral

Function parseLegacyStringLiteral

packages/shared/src/editmode.ts:124–137  ·  view source on GitHub ↗
(raw: string)

Source from the content-addressed store, hash-verified

122}
123
124function parseLegacyStringLiteral(raw: string): string | null {
125 if (raw.length < 2) return null;
126 const quote = raw[0];
127 if ((quote !== '"' && quote !== "'") || raw[raw.length - 1] !== quote) return null;
128 const body = raw.slice(1, -1);
129 if (quote === '"') {
130 try {
131 return JSON.parse(raw) as string;
132 } catch {
133 return null;
134 }
135 }
136 return body.replace(/\\'/g, "'").replace(/\\\\/g, '\\');
137}
138
139function parseLegacyPrimitive(raw: string): EditmodeTokenValue | null {
140 const text = raw.trim();

Callers 2

parseLegacyPrimitiveFunction · 0.85
parseLegacyKeyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected