* RFC 6902 JSON Pointer escaping for an hf-id (bare or scoped). * Scoped ids contain "/" which must be encoded as "~1" in a path segment. * "~" must be encoded as "~0" first (order matters per RFC 6902 §3).
(id: string)
| 36 | * "~" must be encoded as "~0" first (order matters per RFC 6902 §3). |
| 37 | */ |
| 38 | function escapeIdForPath(id: string): string { |
| 39 | return id.replace(/~/g, "~0").replace(/\//g, "~1"); |
| 40 | } |
| 41 | |
| 42 | /** Decode a path segment that may contain RFC 6902-escaped characters back to an hf-id. */ |
| 43 | function decodePathSegment(segment: string): string { |
no outgoing calls
no test coverage detected