stream-http
stream-http copied to clipboard
Fix IPv6 hostname normalization
The old check effectively merged the meaning of host and hostname, which was prone to
errors:
- in rare scenarios
hostcould include:but be ipv4 with a custom port (eg.127.0.0.1:8080) which would produce false-positives - ipv6 could already have square brackets(
[::1]– see the end of this comment), but normalization would run anyway and produced invalid URIs likehttp://[[::1]]:80- this caused issues like example in the wild
This changes ipv6 normalization to only run if actual hostname parameter is
provided, includes : and does not start with [. Also, added missing tests for ipv6.
cc #18, https://github.com/ipfs-shipyard/ipfs-companion/issues/668