Bug 290381 Save As doesn't work on links containing %23 p=caleb r=biesi sr=me

This commit is contained in:
neil%parkwaycc.co.uk 2005-09-18 16:06:20 +00:00
parent 09f3b95dd9
commit 7b4c7db42b

View File

@ -842,15 +842,14 @@ function getNormalizedLeafName(aFile, aDefaultExtension)
if (!aDefaultExtension)
return aFile;
// Fix up the file name we're saving to to include the default extension
const stdURLContractID = "@mozilla.org/network/standard-url;1";
const stdURLIID = Components.interfaces.nsIURL;
var url = Components.classes[stdURLContractID].createInstance(stdURLIID);
url.filePath = aFile;
// Remove trailing dots and spaces on windows
if (/Win/.test(navigator.platform))
aFile = aFile.replace(/[\s.]+$/, "");
if (url.fileExtension != aDefaultExtension) {
// Fix up the file name we're saving to to include the default extension
var i = aFile.lastIndexOf(".");
if (aFile.substr(i + 1) != aDefaultExtension)
return aFile + "." + aDefaultExtension;
}
return aFile;
}