Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
refactor(server/utils): use Set for isStringNote
Panagiotis Papadopoulos440dbfd4d467
diff --git a/src/services/utils.ts b/src/services/utils.tsindex 21649b5b2b..67c415f9f7 100644--- a/src/services/utils.ts+++ b/src/services/utils.ts@@ -132,11 +132,12 @@ export function getContentDisposition(filename: string) {return `file; filename="${sanitizedFilename}"; filename*=UTF-8''${sanitizedFilename}`;}+// render and book are string note in the sense that they are expected to contain empty string+const STRING_NOTE_TYPES = new Set(["text", "code", "relationMap", "search", "render", "book", "mermaid", "canvas"]);const STRING_MIME_TYPES = new Set(["application/javascript", "application/x-javascript", "application/json", "application/x-sql", "image/svg+xml"]);export function isStringNote(type: string | undefined, mime: string) {- // render and book are string note in the sense that they are expected to contain empty string- return (type && ["text", "code", "relationMap", "search", "render", "book", "mermaid", "canvas"].includes(type)) || mime.startsWith("text/") || STRING_MIME_TYPES.has(mime);+ return (type && STRING_NOTE_TYPES.has(type)) || mime.startsWith("text/") || STRING_MIME_TYPES.has(mime);}export function quoteRegex(url: string) {