(key: string | number)
| 6 | * @returns The escaped key. |
| 7 | */ |
| 8 | export 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. |