From 440dbfd4d4672bc76ab65ee018282cc22cd6da80 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Wed, 29 Jan 2025 23:19:08 +0100 Subject: [PATCH] refactor(server/utils): use Set for isStringNote --- src/services/utils.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/services/utils.ts b/src/services/utils.ts index 21649b5b2..67c415f9f 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) {