json-schema-ref-parser
Advanced tools
Comparing version 1.0.0-alpha.6 to 1.0.0-alpha.7
@@ -106,14 +106,4 @@ 'use strict'; | ||
util.debug('Resolving path "%s", relative to "%s"', relative, this); | ||
relative = parseFile({}, relative, options); | ||
relative.path = relative.root = relative.dir = relative.base = relative.name = relative.ext = ''; | ||
if (relative.pathname) { | ||
relative.pathname = path.resolve(this.dir, relative.pathname); | ||
} | ||
else { | ||
relative.pathname = this.pathname; | ||
relative.search = relative.search || this.search; | ||
relative.query = relative.query || this.query; | ||
relative.hash = relative.hash || this.hash; | ||
} | ||
resolved = PathOrUrl.prototype.format.call(relative); | ||
var parsed = parseRelativeFile({}, this, relative, options); | ||
resolved = PathOrUrl.prototype.format.call(parsed); | ||
util.debug(' Resolved to %s', resolved); | ||
@@ -167,8 +157,6 @@ } | ||
// Format as a file path | ||
return path.normalize(clone.pathname + clone.search + clone.hash); | ||
return path.normalize(clone.pathname) + clone.search + clone.hash; | ||
}; | ||
PathOrUrl.prototype.toString = function() { | ||
return this.href; | ||
}; | ||
PathOrUrl.prototype.toString = PathOrUrl.prototype.format; | ||
@@ -196,3 +184,3 @@ PathOrUrl.toUrl = function(href, options) { | ||
if (path.sep !== '/') { | ||
pathname = pathname.replace(new RegExp(path.sep, 'g'), '/'); | ||
pathname = pathname.replace(new RegExp('\\' + path.sep, 'g'), '/'); | ||
} | ||
@@ -257,3 +245,3 @@ | ||
// It's a relative file path | ||
parseFile(this, path.resolve(process.cwd(), href), options); | ||
parseRelativeFile(this, PathOrUrl.cwd(), href, options); | ||
} | ||
@@ -361,2 +349,26 @@ } | ||
/** | ||
* @param {PathOrUrl} target | ||
* @param {PathOrUrl} base | ||
* @param {string} relative | ||
* @param {{allowFileQuery: boolean, allowFileHash: boolean}} [options] | ||
* @returns {{isUrl: boolean, isFile: boolean, url: Url, path: Path}} | ||
*/ | ||
function parseRelativeFile(target, base, relative, options) { | ||
relative = parseFile({}, relative, options); | ||
var absolute; | ||
if (relative.pathname) { | ||
absolute = path.resolve(base.dir, relative.pathname) + relative.search + relative.hash; | ||
} | ||
else if (relative.search) { | ||
absolute = base.pathname + relative.search + relative.hash; | ||
} | ||
else { | ||
absolute = base.pathname + base.search + (relative.hash || base.hash); | ||
} | ||
return parseFile(target, absolute, options); | ||
} | ||
/** | ||
* @param {PathOrUrl} src | ||
@@ -363,0 +375,0 @@ * @param {PathOrUrl} dest |
{ | ||
"name": "json-schema-ref-parser", | ||
"version": "1.0.0-alpha.6", | ||
"version": "1.0.0-alpha.7", | ||
"description": "Parse, Resolve, and Dereference JSON Schema $ref pointers", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
2696235
21092