mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Desktop: Fixed attaching local files that contain spaces in path
Ref: https://discourse.joplinapp.org/t/a-minor-bug-on-linking-to-local-files/13654
This commit is contained in:
parent
0bf3531f51
commit
d75adc3740
@ -66,14 +66,14 @@ describe('pathUtils', function() {
|
|||||||
|
|
||||||
it('should create correct fileURL syntax', (async () => {
|
it('should create correct fileURL syntax', (async () => {
|
||||||
const testCases_win32 = [
|
const testCases_win32 = [
|
||||||
['C:\\handle\\space test', 'file:///C:/handle/space+test'],
|
['C:\\handle\\space test', 'file:///C:/handle/space%20test'],
|
||||||
['C:\\escapeplus\\+', 'file:///C:/escapeplus/%2B'],
|
['C:\\escapeplus\\+', 'file:///C:/escapeplus/%2B'],
|
||||||
['C:\\handle\\single quote\'', 'file:///C:/handle/single+quote%27'],
|
['C:\\handle\\single quote\'', 'file:///C:/handle/single%20quote%27'],
|
||||||
];
|
];
|
||||||
const testCases_unixlike = [
|
const testCases_unixlike = [
|
||||||
['/handle/space test', 'file:///handle/space+test'],
|
['/handle/space test', 'file:///handle/space%20test'],
|
||||||
['/escapeplus/+', 'file:///escapeplus/%2B'],
|
['/escapeplus/+', 'file:///escapeplus/%2B'],
|
||||||
['/handle/single quote\'', 'file:///handle/single+quote%27'],
|
['/handle/single quote\'', 'file:///handle/single%20quote%27'],
|
||||||
];
|
];
|
||||||
|
|
||||||
for (let i = 0; i < testCases_win32.length; i++) {
|
for (let i = 0; i < testCases_win32.length; i++) {
|
||||||
|
@ -528,7 +528,8 @@ function importEnex(parentFolderId, filePath, importOptions = null) {
|
|||||||
if (noteResource.filename) {
|
if (noteResource.filename) {
|
||||||
const mimeTypeFromFile = mime.fromFilename(noteResource.filename);
|
const mimeTypeFromFile = mime.fromFilename(noteResource.filename);
|
||||||
if (mimeTypeFromFile && mimeTypeFromFile !== mimeType) {
|
if (mimeTypeFromFile && mimeTypeFromFile !== mimeType) {
|
||||||
console.info(`Invalid mime type "${mimeType}" for resource "${noteResource.filename}". Using "${mimeTypeFromFile}" instead.`);
|
// Don't print statement by default because it would show up in test units
|
||||||
|
// console.info(`Invalid mime type "${mimeType}" for resource "${noteResource.filename}". Using "${mimeTypeFromFile}" instead.`);
|
||||||
mimeType = mimeTypeFromFile;
|
mimeType = mimeTypeFromFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,6 @@ export function toFileProtocolPath(filePathEncode: string, os: string = null) {
|
|||||||
|
|
||||||
filePathEncode = encodeURI(filePathEncode);
|
filePathEncode = encodeURI(filePathEncode);
|
||||||
filePathEncode = filePathEncode.replace(/\+/g, '%2B'); // escape '+' with unicode
|
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
|
return `file://${filePathEncode.replace(/\'/g, '%27')}`; // escape '(single quote) with unicode, to prevent crashing the html view
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,10 +3,5 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"description": "Sub-package to group official Joplin plugins",
|
"description": "Sub-package to group official Joplin plugins",
|
||||||
"private": true,
|
"private": true,
|
||||||
"main": "index.js",
|
|
||||||
"scripts": {
|
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
|
||||||
},
|
|
||||||
"author": "",
|
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user