mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 18:39:22 +08:00
refactor(server/utils): simplify getNoteTitle
This commit is contained in:
parent
c3587ad536
commit
65be2cf048
@ -182,15 +182,9 @@ export function removeTextFileExtension(filePath: string) {
|
||||
}
|
||||
|
||||
export function getNoteTitle(filePath: string, replaceUnderscoresWithSpaces: boolean, noteMeta?: NoteMeta) {
|
||||
if (noteMeta?.title) {
|
||||
return noteMeta.title;
|
||||
} else {
|
||||
if (noteMeta?.title) return noteMeta.title;
|
||||
const basename = path.basename(removeTextFileExtension(filePath));
|
||||
if (replaceUnderscoresWithSpaces) {
|
||||
return basename.replace(/_/g, " ").trim();
|
||||
}
|
||||
return basename;
|
||||
}
|
||||
return replaceUnderscoresWithSpaces ? basename.replace(/_/g, " ").trim() : basename;
|
||||
}
|
||||
|
||||
export function timeLimit<T>(promise: Promise<T>, limitMs: number, errorMessage?: string): Promise<T> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user