Skip to content

Commit b6f968b

Browse files
authored
Merge pull request #248 from pimterry/fix-tests
chore: fix tests (by fixing error paths generally) when run in paths with spaces
2 parents f6886ab + 736782d commit b6f968b

File tree

4 files changed

+3
-10
lines changed

4 files changed

+3
-10
lines changed

lib/pointer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Pointer.prototype.resolve = function (obj, options, pathFromRoot) {
9191
let token = tokens[i];
9292
if (this.value[token] === undefined || this.value[token] === null) {
9393
this.value = null;
94-
throw new MissingPointerError(token, this.originalPath);
94+
throw new MissingPointerError(token, decodeURI(this.originalPath));
9595
}
9696
else {
9797
this.value = this.value[token];

lib/ref.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ $Ref.prototype.resolve = function (path, options, friendlyPath, pathFromRoot) {
135135
if (err instanceof InvalidPointerError) {
136136
// this is a special case - InvalidPointerError is thrown when dereferencing external file,
137137
// but the issue is caused by the source file that referenced the file that undergoes dereferencing
138-
err.source = stripHash(pathFromRoot);
138+
err.source = decodeURI(stripHash(pathFromRoot));
139139
}
140140

141141
this.addError(err);

lib/resolve-external.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ async function resolve$Ref ($ref, path, $refs, options) {
120120
}
121121

122122
if ($refs._$refs[withoutHash]) {
123-
err.source = url.stripHash(path);
123+
err.source = decodeURI(url.stripHash(path));
124124
err.path = url.safePointerToPath(url.getHash(path));
125125
}
126126

test/specs/error-source/error-source.spec.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const { expect } = chai;
88
const $RefParser = require("../../..");
99
const helper = require("../../utils/helper");
1010
const path = require("../../utils/path");
11-
const { host } = require("@jsdevtools/host-environment");
1211
const { InvalidPointerError, ResolverError, MissingPointerError } = require("../../../lib/util/errors");
1312

1413

@@ -31,12 +30,6 @@ describe("Report correct error source and path for", () => {
3130
}
3231
});
3332

34-
if (host.node && host.os.windows && path.cwd().includes(" ")) {
35-
// The tests below don't support Windows file paths that contain spaces.
36-
// TODO: Fix the tests below, rather than skipping them
37-
return;
38-
}
39-
4033
it("schema with a local reference pointing at property with broken external reference", async () => {
4134
const parser = new $RefParser();
4235
try {

0 commit comments

Comments
 (0)