mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-18 00:02:28 +08:00
refactor(import/mime): simplify getType
This commit is contained in:
parent
91ae4b629e
commit
6a0edb68de
@ -84,16 +84,20 @@ function getMime(fileName: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getType(options: TaskData, mime: 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) {
|
||||||
return "text";
|
case options.textImportedAsText && ["text/html", "text/markdown", "text/x-markdown"].includes(mimeLc):
|
||||||
} else if (options.codeImportedAsCode && CODE_MIME_TYPES.has(mime)) {
|
return "text";
|
||||||
return "code";
|
|
||||||
} else if (mime.startsWith("image/")) {
|
case options.codeImportedAsCode && CODE_MIME_TYPES.has(mimeLc):
|
||||||
return "image";
|
return "code";
|
||||||
} else {
|
|
||||||
return "file";
|
case mime.startsWith("image/"):
|
||||||
|
return "image";
|
||||||
|
|
||||||
|
default:
|
||||||
|
return "file";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user