Comparing version 2.0.4 to 2.0.5
59
index.js
@@ -123,3 +123,3 @@ /* | ||
var u2Details = URI.parse(isType(u2, 'Undefined') ? '' : u2); | ||
var u2Details = parseURI(isType(u2, 'Undefined') ? '' : u2); | ||
var u1Details; | ||
@@ -131,3 +131,3 @@ var combinedDetails; | ||
} else { | ||
u1Details = isType(u1, 'Undefined') ? undefined : URI.parse(u1); | ||
u1Details = isType(u1, 'Undefined') ? undefined : parseURI(u1); | ||
@@ -304,2 +304,4 @@ if (!isType(u1Details, 'Undefined')) { | ||
path.forEach(function (seg) { | ||
seg = decodeURI(seg); | ||
if (seg in value) { | ||
@@ -328,2 +330,21 @@ value = value[seg]; | ||
function getRefType (refDetails) { | ||
var type; | ||
// Convert the URI reference to one of our types | ||
switch (refDetails.uriDetails.reference) { | ||
case 'absolute': | ||
case 'uri': | ||
type = 'remote'; | ||
break; | ||
case 'same-document': | ||
type = 'local'; | ||
break; | ||
default: | ||
type = refDetails.uriDetails.reference; | ||
} | ||
return type; | ||
} | ||
function getRemoteDocument (url, options) { | ||
@@ -413,3 +434,4 @@ var cacheEntry = remoteCache[url]; | ||
return validTypes.indexOf(refDetails.type) > -1; | ||
// Check the exact type or for invalid URIs, check its original type | ||
return validTypes.indexOf(refDetails.type) > -1 || validTypes.indexOf(getRefType(refDetails)) > -1; | ||
}; | ||
@@ -439,4 +461,9 @@ } else if (isType(options.filter, 'Function')) { | ||
function parseURI (uri) { | ||
// We decode first to avoid doubly encoding | ||
return URI.parse(encodeURI(decodeURI(uri))); | ||
} | ||
function setValue (obj, refPath, value) { | ||
findValue(obj, refPath.slice(0, refPath.length - 1))[refPath[refPath.length - 1]] = value; | ||
findValue(obj, refPath.slice(0, refPath.length - 1))[decodeURI(refPath[refPath.length - 1])] = value; | ||
} | ||
@@ -669,3 +696,3 @@ | ||
return seg.replace(/~1/g, '/').replace(/~0/g, '~'); | ||
return decodeURI(seg.replace(/~1/g, '/').replace(/~0/g, '~')); | ||
}); | ||
@@ -761,3 +788,3 @@ } | ||
if (!isType(options.refPreProcessor, 'Undefined')) { | ||
node = options.refPreProcessor(node, path); | ||
node = options.refPreProcessor(clone(node), path); | ||
} | ||
@@ -771,3 +798,3 @@ | ||
if (!isType(options.refPostProcessor, 'Undefined')) { | ||
refDetails = options.refPostProcessor(refDetails, path); | ||
refDetails = options.refPostProcessor(clone(refDetails), path); | ||
} | ||
@@ -893,3 +920,3 @@ | ||
if (isType(uriDetails, 'Undefined')) { | ||
uriDetails = uriDetailsCache[cacheKey] = URI.parse(cacheKey); | ||
uriDetails = uriDetailsCache[cacheKey] = parseURI(cacheKey); | ||
} | ||
@@ -901,14 +928,3 @@ | ||
if (isType(uriDetails.error, 'Undefined')) { | ||
// Convert the URI reference to one of our types | ||
switch (uriDetails.reference) { | ||
case 'absolute': | ||
case 'uri': | ||
details.type = 'remote'; | ||
break; | ||
case 'same-document': | ||
details.type = 'local'; | ||
break; | ||
default: | ||
details.type = uriDetails.reference; | ||
} | ||
details.type = getRefType(details); | ||
} else { | ||
@@ -1007,3 +1023,4 @@ details.error = details.uriDetails.error; | ||
* * The object has a `$ref` property | ||
* * The `$ref` property is a valid URI | ||
* * The `$ref` property is a valid URI *(We do not require 100% strict URIs and will handle unescaped special | ||
* characters.)* | ||
* | ||
@@ -1010,0 +1027,0 @@ * @param {object} obj - The object to check |
{ | ||
"name": "json-refs", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "Various utilities for JSON References (http://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03).", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47819
1130