MCPcopy
hub / github.com/ComposioHQ/composio / escapeStringContent

Function escapeStringContent

ts/packages/ts-builders/src/QuoteStyle.ts:32–46  ·  view source on GitHub ↗
(content: string, quoteStyle: QuoteStyle)

Source from the content-addressed store, hash-verified

30 * Escapes a string content for the specified quote style
31 */
32export function escapeStringContent(content: string, quoteStyle: QuoteStyle): string {
33 switch (quoteStyle) {
34 case QuoteStyle.Double:
35 return JSON.stringify(content);
36
37 case QuoteStyle.Single:
38 return "'" + content.replace(/\\/g, '\\\\').replace(/'/g, "\\'") + "'";
39
40 case QuoteStyle.Backtick:
41 return '`' + content.replace(/\\/g, '\\\\').replace(/`/g, '\\`').replace(/\$/g, '\\$') + '`';
42
43 default:
44 throw new Error(`Unsupported quote style: ${quoteStyle}`);
45 }
46}

Callers 2

QuoteStyle.test.tsFile · 0.90
writeMethod · 0.90

Calls 1

replaceMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…