mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-02 12:47:41 +02:00
Deskop, Cli: Fixes #10125: ENEX does not import correctly when title of note matches the name of the attachment
This commit is contained in:
parent
3d2c100fe9
commit
40db753417
@ -7,9 +7,10 @@
|
|||||||
<updated>20231224T151443Z</updated>
|
<updated>20231224T151443Z</updated>
|
||||||
<content>
|
<content>
|
||||||
<![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note><div><a href="evernote:///view/5223870/s49/9cd5e810-fa03-429a-8194-ab847f2f1ab2/c99d9e01-ca35-4c75-ba63-f0c0ef97787d/" rel="noopener noreferrer" rev="en_rl_none">Note 2</a><a href="evernote:///view/5223870/s49/9cd5e810-fa03-429a-8194-ab847f2f1ab2/c99d9e01-ca35-4c75-ba63-f0c0ef97787d/" rel="noopener noreferrer" rev="en_rl_none">Note 3</a></div></en-note> ]]>
|
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note><div><a href="evernote:///view/5223870/s49/9cd5e810-fa03-429a-8194-ab847f2f1ab2/c99d9e01-ca35-4c75-ba63-f0c0ef97787d/">Note 2</a><a href="evernote:///view/5223870/s49/9cd5e810-fa03-429a-8194-ab847f2f1ab2/c99d9e01-ca35-4c75-ba63-f0c0ef97787d/">Note 3</a></div></en-note> ]]>
|
||||||
</content>
|
</content>
|
||||||
</note>
|
</note>
|
||||||
|
|
||||||
<note>
|
<note>
|
||||||
<title>Note 2</title>
|
<title>Note 2</title>
|
||||||
<created>20160730T111759Z</created>
|
<created>20160730T111759Z</created>
|
||||||
@ -19,15 +20,37 @@
|
|||||||
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note><div>Testing</div></en-note> ]]>
|
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note><div>Testing</div></en-note> ]]>
|
||||||
</content>
|
</content>
|
||||||
</note>
|
</note>
|
||||||
|
|
||||||
<note>
|
<note>
|
||||||
<title>Note 3</title>
|
<title>Note 3</title>
|
||||||
<created>20160730T111759Z</created>
|
<created>20160730T111759Z</created>
|
||||||
<updated>20160730T111807Z</updated>
|
<updated>20160730T111807Z</updated>
|
||||||
<content>
|
<content>
|
||||||
<![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note><div><a href="evernote:///view/5223870/s49/9cd5e810-fa03-429a-8194-ab847f2f1ab2/c99d9e01-ca35-4c75-ba63-f0c0ef97787d/" rel="noopener noreferrer" rev="en_rl_none">Ambiguous note</a></div></en-note> ]]>
|
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note><div><a href="evernote:///view/5223870/s49/9cd5e810-fa03-429a-8194-ab847f2f1ab2/c99d9e01-ca35-4c75-ba63-f0c0ef97787d/">Ambiguous note</a></div></en-note> ]]>
|
||||||
</content>
|
</content>
|
||||||
</note>
|
</note>
|
||||||
|
|
||||||
|
<note>
|
||||||
|
<title>Note 4</title>
|
||||||
|
<created>20160730T111759Z</created>
|
||||||
|
<updated>20160730T111807Z</updated>
|
||||||
|
<content>
|
||||||
|
<![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note><div><a href="https://joplinapp.org">Note 5</a></div></en-note> ]]>
|
||||||
|
</content>
|
||||||
|
</note>
|
||||||
|
|
||||||
|
<note>
|
||||||
|
<title>Note 5</title>
|
||||||
|
<created>20160730T111759Z</created>
|
||||||
|
<updated>20160730T111807Z</updated>
|
||||||
|
<content>
|
||||||
|
<![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note><div></div></en-note> ]]>
|
||||||
|
</content>
|
||||||
|
</note>
|
||||||
|
|
||||||
<note>
|
<note>
|
||||||
<title>Ambiguous note</title>
|
<title>Ambiguous note</title>
|
||||||
<created>20160730T111759Z</created>
|
<created>20160730T111759Z</created>
|
||||||
@ -37,6 +60,7 @@
|
|||||||
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note><div>Testing</div></en-note> ]]>
|
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note><div>Testing</div></en-note> ]]>
|
||||||
</content>
|
</content>
|
||||||
</note>
|
</note>
|
||||||
|
|
||||||
<note>
|
<note>
|
||||||
<title>Ambiguous note</title>
|
<title>Ambiguous note</title>
|
||||||
<created>20160730T111759Z</created>
|
<created>20160730T111759Z</created>
|
||||||
|
@ -227,10 +227,12 @@ describe('import-enex-md-gen', () => {
|
|||||||
const note1 = notes.find(n => n.title === 'Note 1');
|
const note1 = notes.find(n => n.title === 'Note 1');
|
||||||
const note2 = notes.find(n => n.title === 'Note 2');
|
const note2 = notes.find(n => n.title === 'Note 2');
|
||||||
const note3 = notes.find(n => n.title === 'Note 3');
|
const note3 = notes.find(n => n.title === 'Note 3');
|
||||||
|
const note4 = notes.find(n => n.title === 'Note 4');
|
||||||
|
|
||||||
expect(notes.length).toBe(5);
|
expect(notes.length).toBe(7);
|
||||||
expect(note1.body).toBe(`[Note 2](:/${note2.id})[Note 3](:/${note3.id})`);
|
expect(note1.body).toBe(`[Note 2](:/${note2.id})[Note 3](:/${note3.id})`);
|
||||||
expect(note3.body).toBe('[Ambiguous note](evernote:///view/5223870/s49/9cd5e810-fa03-429a-8194-ab847f2f1ab2/c99d9e01-ca35-4c75-ba63-f0c0ef97787d/)');
|
expect(note3.body).toBe('[Ambiguous note](evernote:///view/5223870/s49/9cd5e810-fa03-429a-8194-ab847f2f1ab2/c99d9e01-ca35-4c75-ba63-f0c0ef97787d/)');
|
||||||
|
expect(note4.body).toBe('[Note 5](https://joplinapp.org)');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -293,6 +293,9 @@ const preProcessFile = async (filePath: string): Promise<string> => {
|
|||||||
// return newFilePath;
|
// return newFilePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isEvernoteUrl = (url: string) => {
|
||||||
|
return url.toLowerCase().startsWith('evernote://');
|
||||||
|
};
|
||||||
|
|
||||||
const restoreNoteLinks = async (notes: SavedNote[], noteTitlesToIds: Record<string, string[]>, importOptions: ImportOptions) => {
|
const restoreNoteLinks = async (notes: SavedNote[], noteTitlesToIds: Record<string, string[]>, importOptions: ImportOptions) => {
|
||||||
// --------------------------------------------------------
|
// --------------------------------------------------------
|
||||||
@ -309,6 +312,8 @@ const restoreNoteLinks = async (notes: SavedNote[], noteTitlesToIds: Record<stri
|
|||||||
let noteChanged = false;
|
let noteChanged = false;
|
||||||
|
|
||||||
for (const link of links) {
|
for (const link of links) {
|
||||||
|
if (!isEvernoteUrl(link.url)) continue;
|
||||||
|
|
||||||
const matchingNoteIds = noteTitlesToIds[link.title];
|
const matchingNoteIds = noteTitlesToIds[link.title];
|
||||||
if (matchingNoteIds && matchingNoteIds.length === 1) {
|
if (matchingNoteIds && matchingNoteIds.length === 1) {
|
||||||
note.body = note.body.replace(link.url, `:/${matchingNoteIds[0]}`);
|
note.body = note.body.replace(link.url, `:/${matchingNoteIds[0]}`);
|
||||||
|
Loading…
Reference in New Issue
Block a user