diff --git a/src/mime.js b/src/mime.js index 3d1d06b..37f3578 100644 --- a/src/mime.js +++ b/src/mime.js @@ -9,6 +9,7 @@ const OUTPUT_MIME_TYPES = { tiff: 'image/tiff', avif: 'image/avif', bmp: 'image/bmp', + ico: 'image/x-icon', pdf: 'application/pdf', html: 'text/html', txt: 'text/plain', @@ -39,7 +40,9 @@ const UNDETECTABLE_TEXT_FORMATS = { }; function normalizeFormat(format) { - return format === 'jpg' ? 'jpeg' : format; + if (format === 'jpg') return 'jpeg'; + if (format === 'heif') return 'heic'; + return format; } export async function resolveInputFormat(filePath, declaredFormat) { diff --git a/test/mime.test.js b/test/mime.test.js index f6175f2..1780bce 100644 --- a/test/mime.test.js +++ b/test/mime.test.js @@ -28,6 +28,12 @@ describe('outputMimeType', () => { }); }); +describe('outputMimeType — ico', () => { + it('returns image/x-icon for ico', () => { + expect(outputMimeType('ico')).toBe('image/x-icon'); + }); +}); + describe('resolveInputFormat', () => { it('accepts a PNG file declared as png', async () => { const fixturePath = path.join(import.meta.dirname, 'fixtures', 'sample.png'); @@ -84,3 +90,17 @@ describe('resolveInputFormat', () => { await fs.unlink(fixturePath); }); }); + +describe('resolveInputFormat — heic/heif alias', () => { + it('accepts a HEIC-family file declared as heic', async () => { + const fixturePath = path.join(import.meta.dirname, 'fixtures', 'sample.heic'); + const result = await resolveInputFormat(fixturePath, 'heic'); + expect(result.valid).toBe(true); + }); + + it('accepts the same HEIC-family content declared as heif', async () => { + const fixturePath = path.join(import.meta.dirname, 'fixtures', 'sample.heif'); + const result = await resolveInputFormat(fixturePath, 'heif'); + expect(result.valid).toBe(true); + }); +});