feat(transcode): add markdown file to pdf proxy support

This commit is contained in:
yiling
2026-07-20 18:35:16 +08:00
parent b1d9c1b31b
commit 208eb6898a
9 changed files with 143 additions and 5 deletions
+5 -1
View File
@@ -54,11 +54,15 @@ describe('getProxyType', () => {
expect(getProxyType('audio/mpeg', 'song.mp3')).toBe('audio')
})
it('should detect pdf proxyType only for pdf, csv, and txt files', () => {
it('should detect pdf proxyType only for pdf, csv, txt, and markdown files', () => {
expect(getProxyType('application/pdf', 'doc.pdf')).toBe('pdf')
expect(getProxyType('text/plain', 'notes.txt')).toBe('pdf')
expect(getProxyType('text/csv', 'data.csv')).toBe('pdf')
expect(getProxyType('text/markdown', 'README.md')).toBe('pdf')
expect(getProxyType('text/x-markdown', 'doc.markdown')).toBe('pdf')
expect(getProxyType(null, 'file.txt')).toBe('pdf')
expect(getProxyType(null, 'README.md')).toBe('pdf')
expect(getProxyType(null, 'doc.markdown')).toBe('pdf')
})
it('should return null for unsupported files including office files', () => {
+5 -1
View File
@@ -15,9 +15,13 @@ export function getProxyType(
lowerMediaType === 'application/pdf' ||
lowerMediaType === 'text/plain' ||
lowerMediaType === 'text/csv' ||
lowerMediaType === 'text/markdown' ||
lowerMediaType === 'text/x-markdown' ||
lowerFilename.endsWith('.pdf') ||
lowerFilename.endsWith('.txt') ||
lowerFilename.endsWith('.csv')
lowerFilename.endsWith('.csv') ||
lowerFilename.endsWith('.md') ||
lowerFilename.endsWith('.markdown')
) {
return 'pdf'
}