UNPKG

json8-pointer

Version:
15 lines (13 loc) 425 B
"use strict"; /** * Unescape a JSON Pointer token * * @param {String} token - escaped token * @param {String} separator - separator to use, defaults to / * @return {String} - unescaped token */ module.exports = function unescape(token, separator) { const sep = typeof separator === "string" && separator.length > 0 ? separator : "/"; return token.replace(/~0/g, "~").replace(/~1/g, sep); };