mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-10-20 17:13:44 +00:00
📑 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:
parent
70c91f8afd
commit
b1fee80de4
2 changed files with 14 additions and 0 deletions
|
|
@ -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', () => {
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue