feat: add font MIME types and fix dfont/ico detection collision

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-31 12:57:35 +02:00
co-authored by Claude Sonnet 5
parent 2cde4ec035
commit be50f1f076
2 changed files with 44 additions and 0 deletions
+12
View File
@@ -1,4 +1,6 @@
import { fileTypeFromFile } from 'file-type';
import fs from 'node:fs/promises';
import { probeDfont } from './converters/dfont.js';
const OUTPUT_MIME_TYPES = {
jpg: 'image/jpeg',
@@ -17,6 +19,9 @@ const OUTPUT_MIME_TYPES = {
md: 'text/markdown',
csv: 'text/csv',
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
ttf: 'font/ttf',
otf: 'font/otf',
woff: 'font/woff',
};
export async function detectInputMime(filePath) {
@@ -46,6 +51,13 @@ function normalizeFormat(format) {
}
export async function resolveInputFormat(filePath, declaredFormat) {
if (declaredFormat === 'dfont') {
const buffer = await fs.readFile(filePath);
return probeDfont(buffer)
? { mime: 'application/x-dfont', valid: true }
: { mime: null, valid: false };
}
const detected = await detectInputMime(filePath);
if (!detected) {