mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 12: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)
|
expandPath: function (path)
|
||||||
{
|
{
|
||||||
// TODO: proper pathname separator translation like Vim
|
// TODO: proper pathname separator translation like Vim - this should be done elsewhere
|
||||||
if (WINDOWS)
|
if (WINDOWS)
|
||||||
path = path.replace("/", "\\", "g");
|
path = path.replace("/", "\\", "g");
|
||||||
|
|
||||||
@@ -452,17 +452,25 @@ liberator.IO = function () //{{{
|
|||||||
// also expands relative paths
|
// also expands relative paths
|
||||||
getFile: function (path)
|
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);
|
.createInstance(Components.interfaces.nsILocalFile);
|
||||||
|
let protocolHandler = Components.classes["@mozilla.org/network/protocol;1?name=file"]
|
||||||
|
.createInstance(Components.interfaces.nsIFileProtocolHandler);
|
||||||
|
|
||||||
// convert relative to absolute pathname
|
if (/file:\/\//.test(path))
|
||||||
path = ioManager.expandPath(path);
|
{
|
||||||
if (!/^(file:|[a-zA-Z]:|\/)/.test(path)) // starts not with either /, C: or file:
|
file = protocolHandler.getFileFromURLSpec(path);
|
||||||
path = ioManager.getCurrentDirectory() + (WINDOWS ? "\\" : "/") + path; // TODO: for now homedir, later relative to current dir?
|
}
|
||||||
else
|
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;
|
return file;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user