You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-15 23:00:36 +02:00
Desktop: Create fileURLs via drag and drop (#1653)
* enable drag and drop fileURLs * fix windows fileURL syntax * introduce encodeURI function * fixed encoding issue * use path-utils.js to deal with fileURL path conversion * add changes as requested * Minor rewording 'On the' -> 'In the', additional info about attaching files * change call of toFileProtocolPath * enable test script to check syntax for all OS-platforms
This commit is contained in:
@ -101,9 +101,18 @@ function friendlySafeFilename(e, maxLength = null) {
|
||||
return output.substr(0, maxLength);
|
||||
}
|
||||
|
||||
function toFileProtocolPath(path) {
|
||||
const output = path.replace(/\\/g, "/");
|
||||
return 'file://' + escape(output);
|
||||
function toFileProtocolPath(filePathEncode, os = null) {
|
||||
if (os === null) os = process.platform;
|
||||
|
||||
if (os === 'win32') {
|
||||
filePathEncode = filePathEncode.replace(/\\/g, '/'); // replace backslash in windows pathname with slash e.g. c:\temp to c:/temp
|
||||
filePathEncode = "/" + filePathEncode; // put slash in front of path to comply with windows fileURL syntax
|
||||
}
|
||||
|
||||
filePathEncode = encodeURI(filePathEncode);
|
||||
filePathEncode = filePathEncode.replace(/\+/g, '%2B'); // escape '+' with unicode
|
||||
filePathEncode = filePathEncode.replace(/%20/g, '+'); // switch space (%20) with '+'. To comply with syntax used by joplin, see urldecode_(str) in MdToHtml.js
|
||||
return "file://" + filePathEncode.replace(/\'/g, '%27'); // escape '(single quote) with unicode, to prevent crashing the html view
|
||||
}
|
||||
|
||||
function toSystemSlashes(path, os = null) {
|
||||
|
Reference in New Issue
Block a user