interceptors
interceptors copied to clipboard
Fix Node.js url options parsing
Following of this comment, I revisited the options parsing rules according to Node.js source and docs, and a few insights:
-
host
andhostname
are the same, hostname is preferred if both are specified. - host (and hostname) is
Domain Name
and doesn't include the port. - Node doesn't parse the port from the host. if a user includes the
port
in thehost
, Node refers to it as part of thehost
, and the result is an invalid URL like:http://google.com:1234:80
I also added tests for ipv6.
Last, the current implementation only differs from Node.js in that we return an Invalid URL
instead of firing a bad request. This is due to the fact that we convert options to URL first. However, I believe this behavior is acceptable.
should fix #451