Merge pull request #873 from pano9000/refactor_use_Set

refactor(services): use Set instead of Arrays for faster lookups
This commit is contained in:
Elian Doran
2025-01-02 17:50:35 +02:00
committed by GitHub
4 changed files with 11 additions and 11 deletions

View File

@@ -152,19 +152,19 @@ export function getContentDisposition(filename: string) {
return `file; filename="${sanitizedFilename}"; filename*=UTF-8''${sanitizedFilename}`;
}
const STRING_MIME_TYPES = [
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.includes(mime);
|| STRING_MIME_TYPES.has(mime);
}
export function quoteRegex(url: string) {