Ensure Note's fileName always ends with a .md

We were missing it in some cases :(

Fixes #135
This commit is contained in:
Vishesh Handa
2020-05-13 12:03:04 +02:00
parent 188740974f
commit 31e3e8c806
2 changed files with 7 additions and 4 deletions

View File

@ -59,6 +59,9 @@ class Note with NotesNotifier {
String get filePath {
_filePath ??= p.join(parent.folderPath, getFileName(this));
if (!_filePath.toLowerCase().endsWith('.md')) {
_filePath += '.md';
}
return _filePath;
}

View File

@ -15,15 +15,15 @@ String getFileName(Note note) {
if (note.title.isNotEmpty) {
return buildTitleFileName(note.parent.folderPath, note.title);
} else {
return toSimpleDateTime(date) + ".md";
return toSimpleDateTime(date);
}
break;
case NoteFileNameFormat.Iso8601:
return toIso8601(date) + ".md";
return toIso8601(date);
case NoteFileNameFormat.Iso8601WithTimeZone:
return toIso8601WithTimezone(date) + ".md";
return toIso8601WithTimezone(date);
case NoteFileNameFormat.Iso8601WithTimeZoneWithoutColon:
return toIso8601WithTimezone(date).replaceAll(":", "_") + ".md";
return toIso8601WithTimezone(date).replaceAll(":", "_");
}
return date.toString();