From b1fee80de4d53b518102b7882c25b300c7e7ac83 Mon Sep 17 00:00:00 2001 From: Daniel Lew Date: Sat, 11 Apr 2026 07:23:04 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=91=20fix:=20Alias=20Mimetype=20`text/?= =?UTF-8?q?x-markdown`=20to=20`text/markdown`=20(#12608)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit text/x-markdown is a deprecated version of a markdown mimetype, but we're seeing that sometimes users still send this mimetype. This change allows these files to be uploaded as text/markdown. --- packages/data-provider/src/file-config.spec.ts | 13 +++++++++++++ packages/data-provider/src/file-config.ts | 1 + 2 files changed, 14 insertions(+) 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', }; /**