mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-15 20:17:22 +00:00
fix: refine mime type checks and improve MediaInfoModal layout
Updated tests to check for mime types using `toStartWith` for better validation. Adjusted mime type patterns in DropzoneInner for XML handling. Modified MediaInfoModal to enhance layout responsiveness and broaden text format support for previews, ensuring better file handling and user experience.
This commit is contained in:
@@ -104,7 +104,7 @@ describe("MediaController", () => {
|
||||
body: file,
|
||||
});
|
||||
const result = (await res.json()) as any;
|
||||
expect(result.data.mime_type).toBe("audio/mpeg");
|
||||
expect(result.data.mime_type).toStartWith("audio/mpeg");
|
||||
expect(result.name).toBe(name);
|
||||
|
||||
const destFile = Bun.file(assetsTmpPath + "/" + name);
|
||||
@@ -121,7 +121,7 @@ describe("MediaController", () => {
|
||||
body: file,
|
||||
});
|
||||
const result = (await res.json()) as any;
|
||||
expect(result.data.mime_type).toBe("text/plain");
|
||||
expect(result.data.mime_type).toStartWith("text/plain");
|
||||
expect(result.name).toBe(name);
|
||||
|
||||
const destFile = Bun.file(assetsTmpPath + "/" + name);
|
||||
|
||||
@@ -2,8 +2,8 @@ export const Q = {
|
||||
video: ["mp4", "webm"],
|
||||
audio: ["ogg"],
|
||||
image: ["jpeg", "png", "gif", "webp", "bmp", "tiff", "avif", "heic", "heif"],
|
||||
text: ["html", "css", "mdx", "yaml", "vcard", "csv", "vtt", "xml"],
|
||||
application: ["zip", "toml", "json", "json5", "pdf", "sql"],
|
||||
text: ["html", "css", "mdx", "yaml", "vcard", "csv", "vtt"],
|
||||
application: ["zip", "toml", "json", "json5", "pdf", "xml"],
|
||||
font: ["woff", "woff2", "ttf", "otf"],
|
||||
} as const;
|
||||
|
||||
|
||||
@@ -296,7 +296,7 @@ const Previews = [
|
||||
Icon: TbFileTypeCsv,
|
||||
},
|
||||
{
|
||||
mime: "text/xml",
|
||||
mime: /(text|application)\/xml/,
|
||||
Icon: TbFileTypeXml,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -43,7 +43,7 @@ export function MediaInfoModal({
|
||||
|
||||
return (
|
||||
<div className="flex flex-col md:flex-row">
|
||||
<div className="flex w-full md:w-[calc(100%-300px)] justify-center items-center bg-lightest min-w-0">
|
||||
<div className="flex w-full md:w-[calc(100%-300px)] justify-center items-center bg-lightest min-w-50">
|
||||
<FilePreview file={file} />
|
||||
</div>
|
||||
<div className="w-full md:!w-[300px] flex flex-col">
|
||||
@@ -156,7 +156,7 @@ const Item = ({
|
||||
);
|
||||
};
|
||||
|
||||
const textFormats = [/^text\/.*$/, /application\/(json|ld\+json|javascript|xml|rtf|sql)/];
|
||||
const textFormats = [/^text\/.*$/, /application\/(x\-)?(json|json|yaml|javascript|xml|rtf|sql)/];
|
||||
|
||||
const FilePreview = ({ file }: { file: FileState }) => {
|
||||
const objectUrl = typeof file.body === "string" ? file.body : URL.createObjectURL(file.body);
|
||||
|
||||
Reference in New Issue
Block a user