mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 22:42:26 +01:00
fix Bug#: 19949 - file:// URL loading is broken
This commit is contained in:
@@ -327,7 +327,7 @@ liberator.IO = function () //{{{
|
||||
|
||||
expandPath: function (path)
|
||||
{
|
||||
// TODO: proper pathname separator translation like Vim
|
||||
// TODO: proper pathname separator translation like Vim - this should be done elsewhere
|
||||
if (WINDOWS)
|
||||
path = path.replace("/", "\\", "g");
|
||||
|
||||
@@ -452,17 +452,25 @@ liberator.IO = function () //{{{
|
||||
// also expands relative paths
|
||||
getFile: function (path)
|
||||
{
|
||||
var file = Components.classes["@mozilla.org/file/local;1"]
|
||||
let file = Components.classes["@mozilla.org/file/local;1"]
|
||||
.createInstance(Components.interfaces.nsILocalFile);
|
||||
let protocolHandler = Components.classes["@mozilla.org/network/protocol;1?name=file"]
|
||||
.createInstance(Components.interfaces.nsIFileProtocolHandler);
|
||||
|
||||
// convert relative to absolute pathname
|
||||
path = ioManager.expandPath(path);
|
||||
if (!/^(file:|[a-zA-Z]:|\/)/.test(path)) // starts not with either /, C: or file:
|
||||
path = ioManager.getCurrentDirectory() + (WINDOWS ? "\\" : "/") + path; // TODO: for now homedir, later relative to current dir?
|
||||
if (/file:\/\//.test(path))
|
||||
{
|
||||
file = protocolHandler.getFileFromURLSpec(path);
|
||||
}
|
||||
else
|
||||
path = path.replace(/^file:(\/\/)?/, "");
|
||||
{
|
||||
let expandedPath = ioManager.expandPath(path);
|
||||
|
||||
if (!/^([a-zA-Z]:|\/)/.test(expandedPath)) // doesn't start with /, C:
|
||||
expandedPath = ioManager.getCurrentDirectory() + (WINDOWS ? "\\" : "/") + expandedPath;
|
||||
|
||||
file.initWithPath(expandedPath);
|
||||
}
|
||||
|
||||
file.initWithPath(path);
|
||||
return file;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user