* Checks whether a hostname looks like a real domain name rather than an * SSH config alias. A simple dot-check is not enough because aliases like * "github.com-work" still contain a dot. We additionally require that the * last segment (the TLD) is purely alphabetic — real TLDs (com, org, io, net
(host: string)
| 168 | * never contain hyphens or digits. |
| 169 | */ |
| 170 | function looksLikeRealHostname(host: string): boolean { |
| 171 | if (!host.includes('.')) return false |
| 172 | const lastSegment = host.split('.').pop() |
| 173 | if (!lastSegment) return false |
| 174 | // Real TLDs are purely alphabetic (e.g., "com", "org", "io"). |
| 175 | // SSH aliases like "github.com-work" have a last segment "com-work" which |
| 176 | // contains a hyphen. |
| 177 | return /^[a-zA-Z]+$/.test(lastSegment) |
| 178 | } |