deno.land / x / hono@v4.2.5 / utils / mime.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
export const getMimeType = (filename: string, mimes = baseMimes): string | undefined => { const regexp = /\.([a-zA-Z0-9]+?)$/ const match = filename.match(regexp) if (!match) { return } let mimeType = mimes[match[1]] if ((mimeType && mimeType.startsWith('text')) || mimeType === 'application/json') { mimeType += '; charset=utf-8' } return mimeType}
export const getExtension = (mimeType: string): string | undefined => { for (const ext in baseMimes) { if (baseMimes[ext] === mimeType) { return ext } }}
const baseMimes: Record<string, string> = { aac: 'audio/aac', avi: 'video/x-msvideo', avif: 'image/avif', av1: 'video/av1', bin: 'application/octet-stream', bmp: 'image/bmp', css: 'text/css', csv: 'text/csv', eot: 'application/vnd.ms-fontobject', epub: 'application/epub+zip', gif: 'image/gif', gz: 'application/gzip', htm: 'text/html', html: 'text/html', ico: 'image/x-icon', ics: 'text/calendar', jpeg: 'image/jpeg', jpg: 'image/jpeg', js: 'text/javascript', json: 'application/json', jsonld: 'application/ld+json', map: 'application/json', mid: 'audio/x-midi', midi: 'audio/x-midi', mjs: 'text/javascript', mp3: 'audio/mpeg', mp4: 'video/mp4', mpeg: 'video/mpeg', oga: 'audio/ogg', ogv: 'video/ogg', ogx: 'application/ogg', opus: 'audio/opus', otf: 'font/otf', pdf: 'application/pdf', png: 'image/png', rtf: 'application/rtf', svg: 'image/svg+xml', tif: 'image/tiff', tiff: 'image/tiff', ts: 'video/mp2t', ttf: 'font/ttf', txt: 'text/plain', wasm: 'application/wasm', webm: 'video/webm', weba: 'audio/webm', webp: 'image/webp', woff: 'font/woff', woff2: 'font/woff2', xhtml: 'application/xhtml+xml', xml: 'application/xml', zip: 'application/zip', '3gp': 'video/3gpp', '3g2': 'video/3gpp2', gltf: 'model/gltf+json', glb: 'model/gltf-binary',}
hono

Version Info

Tagged at
a month ago