Fix slash direction on Windows for absolute paths
E.g. Mendeley exports something like `C:/some/path/test.pdf`
This commit is contained in:
parent
f2a887fd24
commit
e861c3e298
1 changed files with 10 additions and 5 deletions
|
@ -329,11 +329,16 @@ Zotero.Translate.ItemSaver.prototype = {
|
||||||
var file;
|
var file;
|
||||||
|
|
||||||
// First, try to parse as absolute path
|
// First, try to parse as absolute path
|
||||||
if(((/^[a-zA-Z]:\\|^\\\\/.test(path) && Zotero.isWin) // Paths starting with drive letter or network shares starting with \\
|
if((/^[a-zA-Z]:[\\\/]|^\\\\/.test(path) && Zotero.isWin) // Paths starting with drive letter or network shares starting with \\
|
||||||
|| (path[0] === "/" && !Zotero.isWin))
|
|| (path[0] === "/" && !Zotero.isWin)) {
|
||||||
&& (file = this._parseAbsolutePath(path))) {
|
// Forward slashes on Windows are not allowed in filenames, so we can
|
||||||
Zotero.debug("Translate: Got file "+path+" as absolute path");
|
// assume they're meant to be backslashes. Backslashes are technically
|
||||||
return file;
|
// allowed on Linux, so the reverse cannot be done reliably.
|
||||||
|
var nativePath = Zotero.isWin ? path.replace('/', '\\', 'g') : path;
|
||||||
|
if (file = this._parseAbsolutePath(nativePath)) {
|
||||||
|
Zotero.debug("Translate: Got file "+nativePath+" as absolute path");
|
||||||
|
return file;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next, try to parse as URI
|
// Next, try to parse as URI
|
||||||
|
|
Loading…
Reference in a new issue