Skip to content

Commit

Permalink
Bug 93141 - Expand ~ to home directory when fixing up file URIs r=mak
Browse files Browse the repository at this point in the history
  • Loading branch information
vinnydiehl committed Aug 14, 2023
1 parent 29d6bd6 commit 11bd76e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docshell/base/URIFixup.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -925,8 +925,8 @@ function fileURIFixup(uriString) {
path = uriString.replace(/\//g, "\\");
}
} else {
// UNIX: Check if it starts with "/".
attemptFixup = uriString.startsWith("/");
// UNIX: Check if it starts with "/" or "~".
attemptFixup = /^[~/]/.test(uriString);
}
if (attemptFixup) {
try {
Expand Down
12 changes: 12 additions & 0 deletions docshell/test/unit/test_URIFixup_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,18 @@ if (AppConstants.platform == "win") {
affectedByDNSForSingleWordHosts: true,
});
} else {
const homeDir = Services.dirsvc.get("Home", Ci.nsIFile).path;

testcases.push({
input: "~",
fixedURI: `file://${homeDir}`,
protocolChange: true,
});
testcases.push({
input: "~/foo",
fixedURI: `file://${homeDir}/foo`,
protocolChange: true,
});
testcases.push({
input: "/some/file.txt",
fixedURI: "file:///some/file.txt",
Expand Down

0 comments on commit 11bd76e

Please sign in to comment.