feat: add ico MIME type and heif->heic extension alias
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+4
-1
@@ -9,6 +9,7 @@ const OUTPUT_MIME_TYPES = {
|
|||||||
tiff: 'image/tiff',
|
tiff: 'image/tiff',
|
||||||
avif: 'image/avif',
|
avif: 'image/avif',
|
||||||
bmp: 'image/bmp',
|
bmp: 'image/bmp',
|
||||||
|
ico: 'image/x-icon',
|
||||||
pdf: 'application/pdf',
|
pdf: 'application/pdf',
|
||||||
html: 'text/html',
|
html: 'text/html',
|
||||||
txt: 'text/plain',
|
txt: 'text/plain',
|
||||||
@@ -39,7 +40,9 @@ const UNDETECTABLE_TEXT_FORMATS = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function normalizeFormat(format) {
|
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) {
|
export async function resolveInputFormat(filePath, declaredFormat) {
|
||||||
|
|||||||
@@ -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', () => {
|
describe('resolveInputFormat', () => {
|
||||||
it('accepts a PNG file declared as png', async () => {
|
it('accepts a PNG file declared as png', async () => {
|
||||||
const fixturePath = path.join(import.meta.dirname, 'fixtures', 'sample.png');
|
const fixturePath = path.join(import.meta.dirname, 'fixtures', 'sample.png');
|
||||||
@@ -84,3 +90,17 @@ describe('resolveInputFormat', () => {
|
|||||||
await fs.unlink(fixturePath);
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user