Skip to content

Commit 9fb8cb5

Browse files
committed
fix(media): normalize detected Matroska MIME
1 parent 7515f08 commit 9fb8cb5

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎packages/media-core/src/mime.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ describe("mime detection", () => {
5151
},
5252
);
5353

54+
it("normalizes byte-detected Matroska to the filename MIME spelling", async () => {
55+
const buffer = Buffer.from("1a45dfa38b4282886d6174726f736b61", "hex");
56+
const detected = await detectMime({ buffer, filePath: "clip.bin" });
57+
58+
expect(detected).toBe("video/x-matroska");
59+
expect(extensionForMime(detected)).toBe(".mkv");
60+
});
61+
5462
it.each([
5563
{ format: "avif", expected: "image/avif" },
5664
{ format: "jpg", expected: "image/jpeg" },

‎packages/media-core/src/mime.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,9 @@ const MIME_SYNONYMS: Record<string, string> = {
162162
"text/yaml": "application/yaml",
163163
"application/x-yaml": "application/yaml",
164164
"application/xml": "text/xml",
165-
// Preserve the shipped AVI filename/header spelling for byte-detected containers.
165+
// Preserve shipped filename/header spellings for byte-detected container aliases.
166166
"video/vnd.avi": "video/x-msvideo",
167+
"video/matroska": "video/x-matroska",
167168
};
168169

169170
/** Normalizes MIME strings by dropping parameters, lowercasing, and folding registered synonyms. */

0 commit comments

Comments
 (0)