MCPcopy Index your code
hub / github.com/Kong/httpsnippet / quote

Function quote

src/helpers/shell.ts:5–16  ·  view source on GitHub ↗
(value = '')

Source from the content-addressed store, hash-verified

3 * see: http://wiki.bash-hackers.org/syntax/quoting#strong_quoting
4 */
5export const quote = (value = '') => {
6 const safe = /^[a-z0-9-_/.@%^=:]+$/i;
7
8 const isShellSafe = safe.test(value);
9
10 if (isShellSafe) {
11 return value;
12 }
13
14 // if the value is not shell safe, then quote it
15 return `'${value.replace(/'/g, "'\\''")}'`;
16};
17
18export const escape = (value: string) => value.replace(/\r/g, '\\r').replace(/\n/g, '\\n');

Callers 3

client.tsFile · 0.90
client.tsFile · 0.90
client.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…