( ext: string, override: Map<string, string> = EXTENSION_LANGUAGE_MAP, )
| 387 | * matches what a native file of that language would get. |
| 388 | */ |
| 389 | export function getLanguageFromExtension( |
| 390 | ext: string, |
| 391 | override: Map<string, string> = EXTENSION_LANGUAGE_MAP, |
| 392 | ): string { |
| 393 | // Normalize so a caller passing an uppercase ext still matches the |
| 394 | // (lowercased) override keys; the only case-sensitive built-in key, `.R`, |
| 395 | // collapses to `.r` with the same value, so this changes nothing else. |
| 396 | const normalized = ext.toLowerCase(); |
| 397 | const target = override.get(normalized) ?? normalized; |
| 398 | return EXTENSION_TO_LANGUAGE[target] || "plaintext"; |
| 399 | } |
no test coverage detected