refactor(import/mime): simplify getType

This commit is contained in:
Panagiotis Papadopoulos 2025-01-20 08:22:31 +01:00
parent 91ae4b629e
commit 6a0edb68de

View File

@ -84,15 +84,19 @@ function getMime(fileName: string) {
}
function getType(options: TaskData, mime: string) {
mime = mime ? mime.toLowerCase() : "";
const mimeLc = mime?.toLowerCase();
if (options.textImportedAsText && (mime === "text/html" || ["text/markdown", "text/x-markdown"].includes(mime))) {
switch (true) {
case options.textImportedAsText && ["text/html", "text/markdown", "text/x-markdown"].includes(mimeLc):
return "text";
} else if (options.codeImportedAsCode && CODE_MIME_TYPES.has(mime)) {
case options.codeImportedAsCode && CODE_MIME_TYPES.has(mimeLc):
return "code";
} else if (mime.startsWith("image/")) {
case mime.startsWith("image/"):
return "image";
} else {
default:
return "file";
}
}