📑 fix: Alias Mimetype text/x-markdown to text/markdown (#12608)

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.
This commit is contained in:
Daniel Lew 2026-04-11 07:23:04 -05:00 • committed by GitHub
parent 70c91f8afd
commit b1fee80de4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View file

@ -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', () => {

View file

@ -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<Record<string, string>> = {
'text/x-python-script': 'text/x-python',
'text/x-markdown': 'text/markdown',
};
/**