mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-13 19:46:16 +03:00
fix(ai): map avif, heic, heif and mov extensions to media types (#58886)
This commit is contained in:
committed by
GitHub
Unverified
parent
b21b21babb
commit
421e44ec8c
@@ -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",
|
||||
|
||||
@@ -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]))
|
||||
|
||||
Reference in New Issue
Block a user