Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/util/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const urlEncodePatterns = [
] as [RegExp, string][];

// RegExp patterns to URL-decode special characters for local filesystem paths
const urlDecodePatterns = [/%23/g, "#", /%24/g, "$", /%26/g, "&", /%2C/g, ",", /%40/g, "@"];
const urlDecodePatterns = [/%23/g, "#", /%24/g, "$", /%26/g, "&", /%2C/g, ",", /%3F/g, "?", /%40/g, "@"];

const unsafeDomainSuffixes = [".localhost", ".local", ".internal", ".intranet", ".corp", ".home", ".lan"];

Expand Down
16 changes: 16 additions & 0 deletions test/specs/util/url.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,19 @@ describe("Handle Linux file paths", () => {
expect($url.toFileSystemPath("FILE:///a/random/Path/file.json")).to.equal("/a/random/Path/file.json");
});
});

describe("Round-trip special characters in filesystem paths", () => {
it("should round-trip a literal question mark", () => {
const original = "/a/random/Path/defs?1.json";
const encoded = $url.fromFileSystemPath(original);
expect(encoded).to.equal("/a/random/Path/defs%3F1.json");
expect($url.toFileSystemPath(encoded)).to.equal(original);
});

it("should round-trip a literal hash", () => {
const original = "/a/random/Path/defs#1.json";
const encoded = $url.fromFileSystemPath(original);
expect(encoded).to.equal("/a/random/Path/defs%231.json");
expect($url.toFileSystemPath(encoded)).to.equal(original);
});
});
Loading