From b36b128d3323872f6692a838915a3577a1b7b7e3 Mon Sep 17 00:00:00 2001 From: Kyle Shockey Date: Thu, 17 May 2018 18:13:37 -0700 Subject: [PATCH] use querystring escaping for $ref value parsing --- src/specmap/lib/refs.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/specmap/lib/refs.js b/src/specmap/lib/refs.js index 44ecc4512..b92491e70 100644 --- a/src/specmap/lib/refs.js +++ b/src/specmap/lib/refs.js @@ -1,4 +1,5 @@ import {fetch} from 'cross-fetch' +import qs from 'querystring' import url from 'url' import lib from '../lib' import createError from '../lib/create-error' @@ -303,7 +304,7 @@ function unescapeJsonPointerToken(token) { if (typeof token !== 'string') { return token } - return token.replace(/~1/g, '/').replace(/~0/g, '~') + return qs.unescape(token.replace(/~1/g, '/').replace(/~0/g, '~')) } /** @@ -311,7 +312,7 @@ function unescapeJsonPointerToken(token) { * @api public */ function escapeJsonPointerToken(token) { - return token.replace(/~/g, '~0').replace(/\//g, '~1') + return qs.escape(token.replace(/~/g, '~0').replace(/\//g, '~1')) } function arrayToJsonPointer(arr) {