From 271f2d1fb552aae01632e63d880c1e1250820285 Mon Sep 17 00:00:00 2001 From: Jamie Brunton Date: Sat, 8 Aug 2026 15:18:28 +0100 Subject: [PATCH] Handle non-string image content types --- src/utils/image.ts | 10 ++++++++-- tests/image-utils.test.ts | 12 +++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/utils/image.ts b/src/utils/image.ts index cd6efc9..f778a69 100644 --- a/src/utils/image.ts +++ b/src/utils/image.ts @@ -16,14 +16,20 @@ export async function downloadImage(url: string, userAgent: string): Promise { it('accepts valid image MIME types', () => { @@ -72,3 +72,13 @@ describe('bufferToBase64', () => { expect(result).toMatch(/^[A-Za-z0-9+/]+=*$/); }); }); + +describe('normalizeContentType', () => { + it('uses the fallback when Axios exposes a non-string header value', () => { + expect(normalizeContentType(['image/png'])).toBe('image/jpeg'); + }); + + it('removes header parameters from a string content type', () => { + expect(normalizeContentType('image/webp; charset=binary')).toBe('image/webp'); + }); +});