* Normalize a user-provided extension key to the `.ext` lowercase form used by * the built-in map. Returns null for keys that can never match a real file * extension (so the caller warns and skips): * - empty / just "." * - multi-part (".d.ts") — language detection keys off the FINAL extensi
(raw: string)
| 93 | * - anything containing a path separator. |
| 94 | */ |
| 95 | function normalizeExtKey(raw: string): string | null { |
| 96 | if (typeof raw !== 'string') return null; |
| 97 | let ext = raw.trim().toLowerCase(); |
| 98 | if (!ext) return null; |
| 99 | if (!ext.startsWith('.')) ext = '.' + ext; |
| 100 | const body = ext.slice(1); |
| 101 | if (!body) return null; |
| 102 | if (body.includes('.') || body.includes('/') || body.includes('\\')) return null; |
| 103 | return ext; |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Read + JSON-parse a `codegraph.json` once and return its validated view. |