(str)
| 1 | // Wrap bare IPv6 in brackets for URL parsing (2+ colons = IPv6) |
| 2 | export const bracketIPv6 = (str) => { |
| 3 | const bare = str.replace(/^https?:\/\//i, ''); |
| 4 | const host = bare.split('/')[0]; |
| 5 | if (!host.startsWith('[') && (host.match(/:/g) || []).length >= 2) |
| 6 | return str.replace(host, `[${host}]`); |
| 7 | return str; |
| 8 | }; |
| 9 | |
| 10 | // Normalise a user-supplied target, stripping :port for DNS lookups |
| 11 | export const parseTarget = (input) => { |
no outgoing calls
no test coverage detected