Comparing version 2.0.2 to 2.0.3
89
index.js
@@ -34,2 +34,3 @@ /* | ||
var dirname = require('path').dirname; | ||
var pathLoader = require('path-loader'); | ||
@@ -209,6 +210,6 @@ var qs = require('querystring'); | ||
// Update the relativeBase based on the new location to retrieve | ||
rOptions.relativeBase = location.substring(0, location.lastIndexOf('/')); | ||
// Remove the relative base | ||
delete rOptions.relativeBase; | ||
return findRefsAt(refDetails.uri, options) | ||
return findRefsAt(location, rOptions) | ||
.then(function (rRefs) { | ||
@@ -235,2 +236,5 @@ // Record the location for circular reference identification | ||
// Update the relative base based on the retrieved location | ||
rOptions.relativeBase = dirname(location); | ||
// Find all important references within the document | ||
@@ -523,5 +527,5 @@ return findAllRefs(rRefs.value, rOptions, parents.concat(location), rParentPath, documents); | ||
* {@link https://github.com/whitlockjc/path-loader/blob/master/docs/API.md#module_PathLoader.load|PathLoader~load} | ||
* @param {module:JsonRefs~RefPreProcessor} [refPreProcessor] - The callback used to pre-process a JSON Reference like | ||
* @param {RefPreProcessor} [refPreProcessor] - The callback used to pre-process a JSON Reference like | ||
* object *(This is called prior to validating the JSON Reference like object and getting its details)* | ||
* @param {module:JsonRefs~RefPostProcessor} [refPostProcessor] - The callback used to post-process the JSON Reference | ||
* @param {RefPostProcessor} [refPostProcessor] - The callback used to post-process the JSON Reference | ||
* metadata *(This is called prior filtering the references)* | ||
@@ -534,4 +538,2 @@ * @param {string} [options.relativeBase] - The base location to use when resolving relative references *(Only useful | ||
* location to search from | ||
* | ||
* @alias module:JsonRefs~JsonRefsOptions | ||
*/ | ||
@@ -544,8 +546,6 @@ | ||
* | ||
* @param {module:JsonRefs~UnresolvedRefDetails} refDetails - The JSON Reference details to test | ||
* @param {UnresolvedRefDetails} refDetails - The JSON Reference details to test | ||
* @param {string[]} path - The path to the JSON Reference | ||
* | ||
* @returns {boolean} whether the JSON Reference should be filtered *(out)* or not | ||
* | ||
* @alias module:JsonRefs~RefDetailsFilter | ||
*/ | ||
@@ -562,4 +562,2 @@ | ||
* @returns {object} the processed JSON Reference like object | ||
* | ||
* @alias module:JsonRefs~RefPreProcessor | ||
*/ | ||
@@ -572,8 +570,6 @@ | ||
* | ||
* @param {module:JsonRefs~UnresolvedRefDetails} refDetails - The JSON Reference details to test | ||
* @param {UnresolvedRefDetails} refDetails - The JSON Reference details to test | ||
* @param {string[]} path - The path to the JSON Reference | ||
* | ||
* @returns {object} the processed JSON Reference details object | ||
* | ||
* @alias module:JsonRefs~RefPostProcessor | ||
*/ | ||
@@ -584,3 +580,3 @@ | ||
* | ||
* @typedef {module:JsonRefs~UnresolvedRefDetails} ResolvedRefDetails | ||
* @typedef {UnresolvedRefDetails} ResolvedRefDetails | ||
* | ||
@@ -592,4 +588,2 @@ * @property {boolean} [circular] - Whether or not the JSON Reference is circular *(Will not be set if the JSON | ||
* @property {*} [value] - The referenced value *(Will not be set if the referenced value is missing)* | ||
* | ||
* @alias module:JsonRefs~ResolvedRefDetails | ||
*/ | ||
@@ -602,7 +596,5 @@ | ||
* | ||
* @property {module:JsonRefs~ResolvedRefDetails} refs - An object whose keys are JSON Pointers *(fragment version)* | ||
* @property {ResolvedRefDetails} refs - An object whose keys are JSON Pointers *(fragment version)* | ||
* to where the JSON Reference is defined and whose values are {@link module:JsonRefs~ResolvedRefDetails} | ||
* @property {object} value - The array/object with its JSON References fully resolved | ||
* | ||
* @alias module:JsonRefs~ResolvedRefsResults | ||
*/ | ||
@@ -615,7 +607,5 @@ | ||
* | ||
* @property {module:JsonRefs~UnresolvedRefDetails} refs - An object whose keys are JSON Pointers *(fragment version)* | ||
* @property {UnresolvedRefDetails} refs - An object whose keys are JSON Pointers *(fragment version)* | ||
* to where the JSON Reference is defined and whose values are {@link module:JsonRefs~UnresolvedRefDetails} | ||
* @property {object} value - The retrieved document | ||
* | ||
* @alias module:JsonRefs~RetrievedRefsResults | ||
*/ | ||
@@ -629,9 +619,7 @@ | ||
* | ||
* @property {module:JsonRefs~UnresolvedRefDetails} refs - An object whose keys are JSON Pointers *(fragment version)* | ||
* @property {UnresolvedRefDetails} refs - An object whose keys are JSON Pointers *(fragment version)* | ||
* to where the JSON Reference is defined and whose values are {@link module:JsonRefs~UnresolvedRefDetails} | ||
* @property {module:JsonRefs~ResolvedRefsResults} - An object whose keys are JSON Pointers *(fragment version)* | ||
* @property {ResolvedRefsResults} - An object whose keys are JSON Pointers *(fragment version)* | ||
* to where the JSON Reference is defined and whose values are {@link module:JsonRefs~ResolvedRefDetails} | ||
* @property {object} value - The retrieved document | ||
* | ||
* @alias module:JsonRefs~RetrievedResolvedRefsResults | ||
*/ | ||
@@ -654,4 +642,2 @@ | ||
* warning)* | ||
* | ||
* @alias module:JsonRefs~UnresolvedRefDetails | ||
*/ | ||
@@ -726,3 +712,3 @@ | ||
* @param {array|object} obj - The structure to find JSON References within | ||
* @param {module:JsonRefs~JsonRefsOptions} [options] - The JsonRefs options | ||
* @param {JsonRefsOptions} [options] - The JsonRefs options | ||
* | ||
@@ -820,3 +806,3 @@ * @returns {object} an object whose keys are JSON Pointers *(fragment version)* to where the JSON Reference is defined | ||
* {@link module:JsonRefs~JsonRefsOptions|options documentation} to see how relative references are handled.)* | ||
* @param {module:JsonRefs~JsonRefsOptions} [options] - The JsonRefs options | ||
* @param {JsonRefsOptions} [options] - The JsonRefs options | ||
* | ||
@@ -848,4 +834,2 @@ * @returns {Promise} a promise that resolves a {@link module:JsonRefs~RetrievedRefsResults} and rejects with an | ||
.then(function () { | ||
var cOptions; | ||
// Validate the provided location | ||
@@ -864,11 +848,6 @@ if (!isType(location, 'String')) { | ||
cOptions = clone(options); | ||
// Combine the location and the optional relative base | ||
location = combineURIs(options.relativeBase, location); | ||
// Set the new relative reference location | ||
cOptions.relativeBase = location.substring(0, location.lastIndexOf('/')); | ||
return getRemoteDocument(location, cOptions); | ||
return getRemoteDocument(location, options); | ||
}) | ||
@@ -905,3 +884,3 @@ .then(function (res) { | ||
* | ||
* @returns {module:JsonRefs~UnresolvedRefDetails} the detailed information | ||
* @returns {UnresolvedRefDetails} the detailed information | ||
* | ||
@@ -981,6 +960,6 @@ * @alias module:JsonRefs.getRefDetails | ||
* | ||
* @alias module:JsonRefs.isPtr | ||
* | ||
* @see {@link https://tools.ietf.org/html/rfc6901#section-3} | ||
* | ||
* @alias module:JsonRefs.isPtr | ||
* | ||
* @example | ||
@@ -1047,6 +1026,6 @@ * // Separating the different ways to invoke isPtr for demonstration purposes | ||
* | ||
* @alias module:JsonRefs.isRef | ||
* | ||
* @see {@link http://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03#section-3} | ||
* | ||
* @alias module:JsonRefs.isRef | ||
* | ||
* @example | ||
@@ -1120,3 +1099,3 @@ * // Separating the different ways to invoke isRef for demonstration purposes | ||
* @param {array|object} obj - The structure to find JSON References within | ||
* @param {module:JsonRefs~JsonRefsOptions} [options] - The JsonRefs options | ||
* @param {JsonRefsOptions} [options] - The JsonRefs options | ||
* | ||
@@ -1269,3 +1248,3 @@ * @returns {Promise} a promise that resolves a {@link module:JsonRefs~ResolvedRefsResults} and rejects with an | ||
* {@link module:JsonRefs~JsonRefsOptions|options documentation} to see how relative references are handled.)* | ||
* @param {module:JsonRefs~JsonRefsOptions} [options] - The JsonRefs options | ||
* @param {JsonRefsOptions} [options] - The JsonRefs options | ||
* | ||
@@ -1296,4 +1275,2 @@ * @returns {Promise} a promise that resolves a {@link module:JsonRefs~RetrievedResolvedRefsResults} and rejects with an | ||
.then(function () { | ||
var cOptions; | ||
// Validate the provided location | ||
@@ -1312,14 +1289,14 @@ if (!isType(location, 'String')) { | ||
cOptions = clone(options); | ||
// Combine the location and the optional relative base | ||
location = combineURIs(options.relativeBase, location); | ||
// Set the new relative reference location | ||
cOptions.relativeBase = location.substring(0, location.lastIndexOf('/')); | ||
return getRemoteDocument(location, cOptions); | ||
return getRemoteDocument(location, options); | ||
}) | ||
.then(function (res) { | ||
return resolveRefs(res, options) | ||
var cOptions = clone(options); | ||
// Update the relative base based on the retrieved location | ||
cOptions.relativeBase = dirname(location); | ||
return resolveRefs(res, cOptions) | ||
.then(function (res2) { | ||
@@ -1326,0 +1303,0 @@ return { |
{ | ||
"name": "json-refs", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"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
47253
1118