mirror of
https://github.com/laurent22/joplin.git
synced 2025-02-01 19:15:01 +02:00
Co-authored-by: Henry Heino <46334387+personalizedrefrigerator@users.noreply.github.com> Co-authored-by: Laurent Cozic <laurent22@users.noreply.github.com>
This commit is contained in:
parent
99a61f1283
commit
3dd008ae9a
@ -446,5 +446,23 @@ describe('interop/InteropService_Exporter_Md', function() {
|
||||
const resourceFilename = (await fs.readdir(`${exportDir()}/_resources`))[0];
|
||||
expect(fileExtension(resourceFilename)).toBe('jpg');
|
||||
}));
|
||||
it('should url encode resource links', (async () => {
|
||||
const folder = await Folder.save({ title: 'testing' });
|
||||
const note = await Note.save({ title: 'mynote', parent_id: folder.id });
|
||||
await shim.attachFileToNote(note, `${supportDir}/photo.jpg`);
|
||||
|
||||
const resource: ResourceEntity = (await Resource.all())[0];
|
||||
await Resource.save({ id: resource.id, title: 'name with spaces.jpg' });
|
||||
|
||||
const service = InteropService.instance();
|
||||
|
||||
await service.export({
|
||||
path: exportDir(),
|
||||
format: 'md',
|
||||
});
|
||||
|
||||
const note_body = await shim.fsDriver().readFile(`${exportDir()}/testing/mynote.md`);
|
||||
expect(note_body).toContain('[photo.jpg](../_resources/name%20with%20spaces.jpg)');
|
||||
}));
|
||||
|
||||
});
|
||||
|
@ -72,7 +72,7 @@ export default class InteropService_Exporter_Md extends InteropService_Exporter_
|
||||
for (let i = 0; i < linkedItemIds.length; i++) {
|
||||
const id = linkedItemIds[i];
|
||||
const itemPath = fn_createRelativePath(paths[id]);
|
||||
newBody = newBody.replace(new RegExp(`:/${id}`, 'g'), itemPath);
|
||||
newBody = newBody.replace(new RegExp(`:/${id}`, 'g'), markdownUtils.escapeLinkUrl(itemPath));
|
||||
}
|
||||
|
||||
return newBody;
|
||||
|
Loading…
x
Reference in New Issue
Block a user