From 6e5e6989ed72db0b8391f930e161eb07394fd3e9 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Fri, 31 Jan 2025 21:52:26 +0100 Subject: [PATCH] fix(server/utils): fix potentially "empty looking" title from getNoteTitle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit when the noteMeta title consists of just spaces, it will fall back to "normal" handling again → instead of showing " " as title, which would be perceived as "empty" --- src/services/utils.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/services/utils.ts b/src/services/utils.ts index b2204b337..964f0708b 100644 --- a/src/services/utils.ts +++ b/src/services/utils.ts @@ -182,7 +182,9 @@ export function removeTextFileExtension(filePath: string) { } export function getNoteTitle(filePath: string, replaceUnderscoresWithSpaces: boolean, noteMeta?: NoteMeta) { - if (noteMeta?.title) return noteMeta.title; + const trimmedNoteMeta = noteMeta?.title?.trim(); + if (trimmedNoteMeta) return trimmedNoteMeta; + const basename = path.basename(removeTextFileExtension(filePath)); return replaceUnderscoresWithSpaces ? basename.replace(/_/g, " ").trim() : basename; }