mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Desktop: Fixes #3267: Fixed issue with invalid image paths when config path contains spaces
This commit is contained in:
parent
b126c761cd
commit
8c338675d2
@ -51,6 +51,21 @@ describe('markdownUtils', function() {
|
||||
}
|
||||
}));
|
||||
|
||||
it('escape a markdown link', asyncTest(async () => {
|
||||
|
||||
const testCases = [
|
||||
['file:///Users/who put spaces in their username??/.config/joplin', 'file:///Users/who%20put%20spaces%20in%20their%20username??/.config/joplin'],
|
||||
['file:///Users/(and brackets???)/.config/joplin', 'file:///Users/%28and%20brackets???%29/.config/joplin'],
|
||||
['file:///Users/thisisfine/.config/joplin', 'file:///Users/thisisfine/.config/joplin'],
|
||||
];
|
||||
|
||||
for (let i = 0; i < testCases.length; i++) {
|
||||
const md = testCases[i][0];
|
||||
const expected = testCases[i][1];
|
||||
expect(markdownUtils.escapeLinkUrl(md)).toBe(expected);
|
||||
}
|
||||
}));
|
||||
|
||||
it('escape a markdown link (title)', asyncTest(async () => {
|
||||
|
||||
const testCases = [
|
||||
|
@ -178,8 +178,6 @@ class MdToHtml {
|
||||
// files. Otherwise some of them might be in the cssStrings property.
|
||||
externalAssetsOnly: false,
|
||||
postMessageSyntax: 'postMessage',
|
||||
// paddingTop: '0',
|
||||
// paddingBottom: '0',
|
||||
highlightedKeywords: [],
|
||||
codeTheme: 'atom-one-light.css',
|
||||
theme: Object.assign({}, defaultNoteStyle, theme),
|
||||
|
@ -18,6 +18,7 @@ const markdownUtils = {
|
||||
escapeLinkUrl(url) {
|
||||
url = url.replace(/\(/g, '%28');
|
||||
url = url.replace(/\)/g, '%29');
|
||||
url = url.replace(/ /g, '%20');
|
||||
return url;
|
||||
},
|
||||
|
||||
|
@ -149,7 +149,7 @@ class Note extends BaseItem {
|
||||
const resource = await Resource.load(id);
|
||||
if (!resource) continue;
|
||||
const resourcePath = options.useAbsolutePaths ? `file://${Resource.fullPath(resource)}` : Resource.relativePath(resource);
|
||||
body = body.replace(new RegExp(`:/${id}`, 'gi'), resourcePath);
|
||||
body = body.replace(new RegExp(`:/${id}`, 'gi'), markdownUtils.escapeLinkUrl(resourcePath));
|
||||
}
|
||||
|
||||
this.logger().info('replaceResourceInternalToExternalLinks result', body);
|
||||
|
Loading…
Reference in New Issue
Block a user