fix(ai): map avif, heic, heif and mov extensions to media types (#58886)

This commit is contained in:
Aiden Cline
2026-10-26 00:04:20 -05:00
committed by GitHub
Unverified
parent b21b21babb
commit 421e44ec8c
2 changed files with 14 additions and 0 deletions
+4
View File
@@ -53,8 +53,12 @@ const EXTENSIONS: Readonly<Record<string, string>> = {
jpeg: "image/jpeg",
gif: "image/gif",
webp: "image/webp",
avif: "image/avif",
heic: "image/heic",
heif: "image/heif",
pdf: "application/pdf",
mp4: "video/mp4",
mov: "video/quicktime",
webm: "video/webm",
mp3: "audio/mpeg",
m4a: "audio/mp4",
+10
View File
@@ -291,6 +291,16 @@ describe("Media", () => {
yield* fs.writeFile(plain, new TextEncoder().encode("# hi"))
expect((yield* Media.file(plain)).mediaType).toBe("text/markdown")
for (const [name, mediaType] of [
["photo.avif", "image/avif"],
["photo.HEIC", "image/heic"],
["photo.heif", "image/heif"],
["clip.mov", "video/quicktime"],
]) {
yield* fs.writeFile(`${dir}/${name}`, Uint8Array.from([1, 2, 3]))
expect((yield* Media.file(`${dir}/${name}`)).mediaType).toBe(mediaType)
}
const target = `${dir}/copy.png`
yield* Media.write(Media.base64("AQID", "image/png"), target)
expect(yield* fs.readFile(target)).toEqual(Uint8Array.from([1, 2, 3]))