MCPcopy
hub / github.com/loggerhead/json4u / escape

Function escape

src/lib/idgen/pointer.ts:8–13  ·  view source on GitHub ↗
(key: string | number)

Source from the content-addressed store, hash-verified

6 * @returns The escaped key.
7 */
8export function escape(key: string | number): string {
9 return String(key)
10 .replace(/~/g, "~0")
11 .replace(/\//g, "~1")
12 .replace(/["%\s&$]/g, encodeURIComponent);
13}
14
15/**
16 * Unescapes a key from a JSON pointer.

Callers 1

toStringMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected