(path: string)
| 52 | // match is case-insensitive. Returns DEFAULT_CONTENT_TYPE when the |
| 53 | // path has no extension or the extension isn't in the table. |
| 54 | export function contentTypeForPath(path: string): string { |
| 55 | const base = path.slice(path.lastIndexOf("/") + 1); |
| 56 | const dot = base.lastIndexOf("."); |
| 57 | if (dot <= 0) return DEFAULT_CONTENT_TYPE; |
| 58 | const ext = base.slice(dot + 1).toLowerCase(); |
| 59 | return TYPES[ext] ?? DEFAULT_CONTENT_TYPE; |
| 60 | } |
no outgoing calls
no test coverage detected