mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-17 12:56:05 +00:00
media: added more mime types, added mime type check on dropzone
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
export const Q = {
|
||||
video: ["mp4", "webm"],
|
||||
audio: ["ogg"],
|
||||
image: ["jpeg", "png", "gif", "webp", "bmp", "tiff"],
|
||||
image: ["jpeg", "png", "gif", "webp", "bmp", "tiff", "avif", "heic", "heif"],
|
||||
text: ["html", "css", "mdx", "yaml", "vcard", "csv", "vtt"],
|
||||
application: ["zip", "xml", "toml", "json", "json5"],
|
||||
font: ["woff", "woff2", "ttf", "otf"]
|
||||
@@ -76,7 +76,8 @@ export function guess(f: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
export function isMimeType(mime: any, exclude: string[] = []) {
|
||||
export function isMimeType(_mime: any, exclude: string[] = []) {
|
||||
const mime = _mime.toLowerCase();
|
||||
if (exclude.includes(mime)) return false;
|
||||
|
||||
// try quick first
|
||||
@@ -96,7 +97,9 @@ export function isMimeType(mime: any, exclude: string[] = []) {
|
||||
return false;
|
||||
}
|
||||
|
||||
export function extension(mime: string) {
|
||||
export function extension(_mime: string) {
|
||||
const mime = _mime.toLowerCase();
|
||||
|
||||
for (const [t, e] of Object.entries(Q)) {
|
||||
for (const _e of e) {
|
||||
if (mime === `${t}/${_e}`) {
|
||||
|
||||
@@ -5,7 +5,7 @@ export function getExtensionFromName(filename: string): string | undefined {
|
||||
if (!filename.includes(".")) return;
|
||||
|
||||
const parts = filename.split(".");
|
||||
return parts[parts.length - 1];
|
||||
return parts[parts.length - 1]?.toLowerCase();
|
||||
}
|
||||
|
||||
export function getRandomizedFilename(file: File, length?: number): string;
|
||||
|
||||
Reference in New Issue
Block a user