Skip to content
This repository was archived by the owner on May 5, 2024. It is now read-only.

Commit 14a980d

Browse files
feat: add filePathToContentType() function
1 parent 53ed431 commit 14a980d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

filePathToContentType.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export function filePathToContentType(filePath: string) {
2+
return filePath.endsWith('.jsx')
3+
? 'text/jsx'
4+
: filePath.endsWith('.tsx')
5+
? 'text/tsx'
6+
: filePath.endsWith('.js') || filePath.endsWith('.mjs')
7+
? 'text/javascript'
8+
: filePath.endsWith('.ts')
9+
? 'text/typescript'
10+
: filePath.endsWith('.json')
11+
? 'application/json'
12+
: filePath.endsWith('.wasm')
13+
? 'application/wasm'
14+
: 'text/plain'
15+
}

0 commit comments

Comments
 (0)