Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,16 @@ $RefParser.prototype.parse = function (path, schema, options, callback) {
pathType = 'file';
}

// Resolve the absolute path of the schema
args.path = url.resolve(url.cwd(), args.path);

if (args.schema && typeof args.schema === 'object') {
// A schema object was passed-in.
if (args.schema.$id) { // if an id is passed it will use the base uri for the path of the object
var u = url.parse(args.schema.$id);
args.path = u.protocol + '//' + u.host + '/#';
}
else {
args.path = url.resolve(url.cwd(), args.path);
}
// So immediately add a new $Ref with the schema object as its value
var $ref = this.$refs._add(args.path);
$ref.value = args.schema;
Expand All @@ -104,6 +109,8 @@ $RefParser.prototype.parse = function (path, schema, options, callback) {
}
else {
// Parse the schema file/url
// Resolve the absolute path of the schema
args.path = url.resolve(url.cwd(), args.path);
promise = parse(args.path, this.$refs, args.options);
}

Expand Down