Bug 290381: "Save Link As..." doubles the extension if the link contains an escaped hash/pound (#) sign encoded as %23, patch by Caleb <bugs.caleb@gmail.com>, r=mconnor

This commit is contained in:
gavin%gavinsharp.com 2005-09-17 02:27:45 +00:00
parent a8a03036c3
commit d6917672bf

View File

@ -884,14 +884,15 @@ function getNormalizedLeafName(aFile, aDefaultExtension)
{
if (!aDefaultExtension)
return aFile;
#ifdef XP_WIN
// Remove trailing dots and spaces on windows
aFile = aFile.replace(/[\s.]+$/, "");
#endif
// 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;
if (url.fileExtension != aDefaultExtension)
var i = aFile.lastIndexOf(".");
if (aFile.substr(i + 1) != aDefaultExtension)
return aFile + "." + aDefaultExtension;
return aFile;