Fixes #192, double-clicking webpage snapshots sometimes brings up a save dialog

On Simon's suggestion, appending .html to all text/html files--I can't reproduce the problem, and I'm not sure what's causing the ExternalHelperAppService to get confused, but this should at least avoid the issue...
This commit is contained in:
Dan Stillman 2006-08-18 07:06:01 +00:00
parent 20486d5053
commit 73cc7b8707

View file

@ -2049,7 +2049,19 @@ Scholar.Attachments = new function(){
var file = Components.classes["@mozilla.org/file/local;1"].
createInstance(Components.interfaces.nsILocalFile);
file.initWithFile(destDir);
file.append(_getFileNameFromURL(url, mimeType));
var fileName = _getFileNameFromURL(url, mimeType);
// This is a hack to make sure the file is opened in the browser when
// we use loadURI(), since Firefox's internal detection mechanisms seem
// to sometimes get confused
// (see #192, https://chnm.gmu.edu/trac/scholar/ticket/192)
if (mimeType=='text/html' &&
(fileName.substr(0, fileName.length-5)!='.html'
|| fileName.substr(0, fileName.length-4)!='.htm')){
fileName += '.html';
}
file.append(fileName);
wbp.saveDocument(document, file, destDir, mimeType, encodingFlags, false);