From 132b3ddcb8501870a62f1b709a428135500fb411 Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Wed, 13 May 2020 12:09:54 +0200 Subject: [PATCH] Sanitize the filename derived from the note's title Not all characters are supported on all platforms. Additionally, we don't want it to have the path seperator. Fixes #132 --- lib/core/note_fileName.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/core/note_fileName.dart b/lib/core/note_fileName.dart index 199a5fec..66601459 100644 --- a/lib/core/note_fileName.dart +++ b/lib/core/note_fileName.dart @@ -30,6 +30,9 @@ String getFileName(Note note) { } String buildTitleFileName(String parentDir, String title) { + // Sanitize the title - these characters are not allowed in Windows + title = title.replaceAll(RegExp(r'[/<\>":|?*]'), '_'); + var fileName = title + ".md"; var fullPath = p.join(parentDir, fileName); var file = File(fullPath);