feat: add MIME plumbing for markdown (.md) format

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-31 08:29:55 +02:00
co-authored by Claude Sonnet 5
parent 7d61209bd8
commit 28b6edac82
4 changed files with 132 additions and 0 deletions
+12
View File
@@ -20,6 +20,7 @@ describe('outputMimeType', () => {
expect(outputMimeType('docx')).toBe(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
);
expect(outputMimeType('md')).toBe('text/markdown');
});
it('throws for an unknown target format', () => {
@@ -61,6 +62,17 @@ describe('resolveInputFormat', () => {
await fs.unlink(fixturePath);
});
it('trusts the declared format for undetectable md files', async () => {
const fixturePath = path.join(import.meta.dirname, 'fixtures', 'sample.md');
await fs.writeFile(fixturePath, '# plain markdown, no magic bytes');
const result = await resolveInputFormat(fixturePath, 'md');
expect(result).toEqual({ mime: 'text/markdown', valid: true });
await fs.unlink(fixturePath);
});
it('rejects an undetectable file declared as a binary format', async () => {
const fixturePath = path.join(import.meta.dirname, 'fixtures', 'sample-fake.png');
await fs.writeFile(fixturePath, 'this is not really a PNG');