diff --git a/packages/data-provider/src/file-config.spec.ts b/packages/data-provider/src/file-config.spec.ts index ee894712ff..ec846af5a4 100644 --- a/packages/data-provider/src/file-config.spec.ts +++ b/packages/data-provider/src/file-config.spec.ts @@ -19,6 +19,10 @@ describe('inferMimeType', () => { expect(inferMimeType('test.py', 'text/x-python-script')).toBe('text/x-python'); }); + it('should normalize text/x-markdown to text/markdown', () => { + expect(inferMimeType('test.md', 'text/x-markdown')).toBe('text/markdown'); + }); + it('should return a type that matches textMimeTypes after normalization', () => { const normalized = inferMimeType('test.py', 'text/x-python-script'); expect(textMimeTypes.test(normalized)).toBe(true); @@ -45,9 +49,18 @@ describe('inferMimeType', () => { expect(baseFileConfig.checkType(normalized)).toBe(true); }); + it('should produce a type accepted by checkType after normalizing text/x-markdown', () => { + const normalized = inferMimeType('test.md', 'text/x-markdown'); + expect(baseFileConfig.checkType(normalized)).toBe(true); + }); + it('should reject raw text/x-python-script without normalization', () => { expect(baseFileConfig.checkType('text/x-python-script')).toBe(false); }); + + it('should reject raw text/x-markdown without normalization', () => { + expect(baseFileConfig.checkType('text/x-markdown')).toBe(false); + }); }); describe('applicationMimeTypes', () => { diff --git a/packages/data-provider/src/file-config.ts b/packages/data-provider/src/file-config.ts index a93daf79e2..2a29b46943 100644 --- a/packages/data-provider/src/file-config.ts +++ b/packages/data-provider/src/file-config.ts @@ -362,6 +362,7 @@ export const imageTypeMapping: { [key: string]: string } = { /** Normalizes non-standard MIME types that browsers may report to their canonical forms */ export const mimeTypeAliases: Readonly> = { 'text/x-python-script': 'text/x-python', + 'text/x-markdown': 'text/markdown', }; /**