Skip to content

Commit

Permalink
fix: handling enex filenames containing multiple dots (#456)
Browse files Browse the repository at this point in the history
  • Loading branch information
akosbalasko authored Feb 28, 2023
1 parent cac0bb5 commit 61a4275
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/folder-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const setPaths = (enexSource: string): void => {
// loggerInfo('setting paths');
const enexFolder = enexSource.split(path.sep);
// loggerInfo(`enex folder split: ${JSON.stringify(enexFolder)}`);
const enexFile = (enexFolder.length >= 1 ? enexFolder[enexFolder.length - 1] : enexFolder[0]).split('.')[0];
const enexFile = (enexFolder.length >= 1 ? enexFolder[enexFolder.length - 1] : enexFolder[0]).split(/.enex$/)[0];
// loggerInfo(`enex file: ${enexFile}`);

const outputDir = path.isAbsolute(yarleOptions.outputDir)
Expand Down
5 changes: 5 additions & 0 deletions test/data/test.dots.in.enex.File.Name.enex
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE en-export SYSTEM "http://xml.evernote.com/pub/evernote-export3.dtd">
<en-export export-date="20181006T112423Z" application="Evernote" version="Evernote Mac 7.5 (457109)">
<note><title>test.dots.in.enex.File.Name</title><content><![CDATA[<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note><div>This is the content</div></en-note>]]></content><created>20181006T084349Z</created><updated>20181006T084411Z</updated><tag>tag1</tag><tag>tag2</tag><note-attributes><author>akos</author><source>desktop.mac</source><reminder-order>0</reminder-order></note-attributes></note>
</en-export>
14 changes: 14 additions & 0 deletions test/data/test.dots.in.enex.File.Name.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# test.dots.in.enex.File.Name


---
Tags: ["tag1","tag2"]

---


This is the content

Created at: 2018-10-06T09:43:49+01:00
Updated at: 2018-10-06T09:44:11+01:00
Notebook: test.dots.in.enex.File.Name
32 changes: 32 additions & 0 deletions test/yarle-special-cases.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1088,4 +1088,36 @@ dateFormat: undefined,
fs.readFileSync(`${__dirname}/data/test -note with tags array.md`, 'utf8'),
);
});



it('dots in enex file name', async () => {
const options: YarleOptions = {
dateFormat: undefined,
enexSources: [ `${testDataFolder}test.dots.in.enex.File.Name.enex` ],
outputDir: 'out',
templateFile: `${testDataFolder}tags-array_template.templ`,
isMetadataNeeded: true,
outputFormat: OutputFormat.ObsidianMD,
skipEnexFileNameFromOutputPath: false,
skipTags: false,
useHashTags: false,

};
await yarle.dropTheRope(options);
assert.equal(
fs.existsSync(
`${__dirname}/../out/notes/test.dots.in.enex.File.Name/test.dots.in.enex.File.Name.md`,
),
true,
);
assert.equal(
eol.auto(fs.readFileSync(
`${__dirname}/../out/notes/test.dots.in.enex.File.Name/test.dots.in.enex.File.Name.md`,
'utf8',
)),
fs.readFileSync(`${__dirname}/data/test.dots.in.enex.File.Name.md`, 'utf8'),
);
});

});

0 comments on commit 61a4275

Please sign in to comment.