core.unescapetoken | Medplum
unescapeToken() function
Unescape token part of a JSON Pointer string
token should not contain any '/' characters.
Evaluation of each reference token begins by decoding any escaped character sequence. This is performed by first transforming any occurrence of the sequence '1' to '/', and then transforming any occurrence of the sequence '0' to ''. By performing the substitutions in this order, an implementation avoids the error of turning '01' first into '1' and then into '/', which would be incorrect (the string '01' correctly becomes '~1' after transformation).
Here's my take:
1 is unescaped with higher priority than ~0 because it is a lower-order escape character. I say "lower order" because '/' needs escaping due to the JSON Pointer serialization technique. Whereas, '' is escaped because escaping '/' uses the '~' character.
Signature:
export declare function unescapeToken(token: string): string;
Parameters
| Parameter | Type | Description |
|---|---|---|
| token | string | The token to unescape. |
Returns:
string
The unescaped token.