fix(media-core): normalize GIF content type detection (#96435) · openclaw/openclaw@47d3d1b
lin-hongkuan
·
2026-06-25
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -8,6 +8,7 @@ import {
|
8 | 8 | FILE_TYPE_SNIFF_MAX_BYTES, |
9 | 9 | imageMimeFromFormat, |
10 | 10 | isAudioFileName, |
| 11 | +isGifMedia, |
11 | 12 | kindFromMime, |
12 | 13 | mimeTypeFromFilePath, |
13 | 14 | normalizeMimeType, |
@@ -271,6 +272,29 @@ describe("isAudioFileName", () => {
|
271 | 272 | }); |
272 | 273 | }); |
273 | 274 | |
| 275 | +describe("isGifMedia", () => { |
| 276 | +it.each([ |
| 277 | +{ |
| 278 | +opts: { contentType: "image/gif; charset=binary" }, |
| 279 | +expected: true, |
| 280 | +}, |
| 281 | +{ |
| 282 | +opts: { contentType: " IMAGE/GIF " }, |
| 283 | +expected: true, |
| 284 | +}, |
| 285 | +{ |
| 286 | +opts: { contentType: "image/png" }, |
| 287 | +expected: false, |
| 288 | +}, |
| 289 | +{ |
| 290 | +opts: { fileName: "animation.GIF" }, |
| 291 | +expected: true, |
| 292 | +}, |
| 293 | +] as const)("detects GIF media from normalized metadata %#", ({ opts, expected }) => { |
| 294 | +expect(isGifMedia(opts)).toBe(expected); |
| 295 | +}); |
| 296 | +}); |
| 297 | + |
274 | 298 | describe("normalizeMimeType", () => { |
275 | 299 | function expectNormalizedMimeCase( |
276 | 300 | input: Parameters<typeof normalizeMimeType>[0], |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。