Skip to content

Commit

Permalink
fix(server/utils): fix potentially "empty looking" title from getNote…
Browse files Browse the repository at this point in the history
…Title

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"
  • Loading branch information
pano9000 committed Jan 31, 2025
1 parent 074a0eb commit cc485b8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/services/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit cc485b8

Please sign in to comment.