You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-08-10 22:11:50 +02:00
Desktop: Fixes #12362: Fixed import of Markdown files that contain links with Windows paths (#12386)
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
<img src="..\\..\\photo.jpg" />
|
||||
<a href="..\\..\\sample.txt">Sample</a>
|
@@ -220,6 +220,14 @@ describe('InteropService_Importer_Md', () => {
|
||||
expect(note.body).toContain('');
|
||||
});
|
||||
|
||||
it('should import resources from links with Windows path', async () => {
|
||||
const note = await importNote(`${supportDir}/test_notes/md/windows_path.html`);
|
||||
const items = await Note.linkedItems(note.body);
|
||||
expect(items.length).toBe(2);
|
||||
expect(items.find(i => i.title === 'sample.txt')).toBeTruthy();
|
||||
expect(items.find(i => i.title === 'photo.jpg')).toBeTruthy();
|
||||
});
|
||||
|
||||
it.each([
|
||||
['<a name="525"/>', '<a name="525"></a>'],
|
||||
['<a name="525" id="test" class="link"/>', '<a name="525" id="test" class="link"></a>'],
|
||||
|
@@ -5,7 +5,7 @@ import InteropService_Importer_Base from './InteropService_Importer_Base';
|
||||
import Folder from '../../models/Folder';
|
||||
import Note from '../../models/Note';
|
||||
import { NoteEntity } from '../database/types';
|
||||
import { basename, filename, rtrimSlashes, fileExtension, dirname } from '../../path-utils';
|
||||
import { basename, filename, rtrimSlashes, fileExtension, dirname, toForwardSlashes } from '../../path-utils';
|
||||
import shim from '../../shim';
|
||||
import markdownUtils from '../../markdownUtils';
|
||||
import htmlUtils from '../../htmlUtils';
|
||||
@@ -124,7 +124,8 @@ export default class InteropService_Importer_Md extends InteropService_Importer_
|
||||
continue;
|
||||
} else {
|
||||
// Handle anchor links appropriately
|
||||
const trimmedLink = this.trimAnchorLink(link);
|
||||
const linkPosix = toForwardSlashes(link);
|
||||
const trimmedLink = this.trimAnchorLink(linkPosix);
|
||||
const attachmentPath = filename(`${dirname(filePath)}/${trimmedLink}`, true);
|
||||
const pathWithExtension = `${attachmentPath}.${fileExtension(trimmedLink)}`;
|
||||
const stat = await shim.fsDriver().stat(pathWithExtension);
|
||||
|
Reference in New Issue
Block a user