Skip to content

Commit

Permalink
use querystring escaping for $ref value parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
shockey committed May 19, 2018
1 parent 3a57210 commit b36b128
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/specmap/lib/refs.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -303,15 +304,15 @@ 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, '~'))
}

/**
* Escapes a JSON pointer.
* @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) {
Expand Down

0 comments on commit b36b128

Please sign in to comment.