* 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)
| 126 | * - anything containing a path separator. |
| 127 | */ |
| 128 | function normalizeExtKey(raw: string): string | null { |
| 129 | if (typeof raw !== 'string') return null; |
| 130 | let ext = raw.trim().toLowerCase(); |
| 131 | if (!ext) return null; |
| 132 | if (!ext.startsWith('.')) ext = '.' + ext; |
| 133 | const body = ext.slice(1); |
| 134 | if (!body) return null; |
| 135 | if (body.includes('.') || body.includes('/') || body.includes('\\')) return null; |
| 136 | return ext; |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * Read + JSON-parse a `codegraph.json` once and return its validated view. |