-
-
Notifications
You must be signed in to change notification settings - Fork 424
Expand file tree
/
Copy pathfile-types.ts
More file actions
31 lines (30 loc) · 790 Bytes
/
file-types.ts
File metadata and controls
31 lines (30 loc) · 790 Bytes
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
// MIME types that are binary and cannot be meaningfully displayed as text
const BINARY_MIME_PREFIXES = new Set([
'image/',
'audio/',
'video/',
'font/',
'application/wasm',
'application/pdf',
'application/zip',
'application/x-rar-compressed',
'application/x-7z-compressed',
'application/x-gzip',
'application/x-tar',
'application/x-bz2',
'application/x-xz',
'application/x-executable',
'application/x-msdownload', // exe / dll
'application/x-sharedlib', // so / dylib
'application/msword', // .doc
'application/vnd.',
'application/octet-stream',
])
export function isBinaryContentType(contentType: string): boolean {
for (const prefix of BINARY_MIME_PREFIXES) {
if (contentType.startsWith(prefix)) {
return true
}
}
return false
}