Bug 93141 - Expand `~` to home directory when fixing up file URIs r=mak

Differential Revision: https://phabricator.services.mozilla.com/D185562
This commit is contained in:
Vinny Diehl 2023-08-14 07:45:56 +00:00
Родитель 29d6bd6af7
Коммит 11bd76e996
2 изменённых файлов: 14 добавлений и 2 удалений

Просмотреть файл

@ -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 {

Просмотреть файл

@ -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",