From 31e3e8c806e283855c5cd214062a98acfdaf7f61 Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Wed, 13 May 2020 12:03:04 +0200 Subject: [PATCH] Ensure Note's fileName always ends with a .md We were missing it in some cases :( Fixes #135 --- lib/core/note.dart | 3 +++ lib/core/note_fileName.dart | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/core/note.dart b/lib/core/note.dart index 71bddb32..2e117a95 100644 --- a/lib/core/note.dart +++ b/lib/core/note.dart @@ -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; } diff --git a/lib/core/note_fileName.dart b/lib/core/note_fileName.dart index 04493756..199a5fec 100644 --- a/lib/core/note_fileName.dart +++ b/lib/core/note_fileName.dart @@ -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();