Handle non-string image content types
This commit is contained in:
1 parent
51438aa5db
commit
271f2d1fb5
2 files changed
+19
-3
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { isValidImageMimeType, bufferToBase64 } from '../src/utils/image.js';
|
||||
import { isValidImageMimeType, bufferToBase64, normalizeContentType } from '../src/utils/image.js';
|
||||
|
||||
describe('isValidImageMimeType', () => {
|
||||
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');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user