-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The deprecated url.format formats ipv6 localhost address wrongly #36654
Comments
The problem as I see it is not with console.log(url.format({ protocol: 'http', host: '[::]' })); Also both url.format(new URL('http://[::]')); and url.format(url.parse('http://[::]')); work as expected. When using We can document this behavior or make |
If we recognize > const url = require('url');
> console.log(url.format({ protocol: 'http', host: '[::]', port: 3000 }));
http://[::] It would be more reasonable to make
|
I find it a bit surprising that the WHATWG URL hostname getter returns |
Fixes: #36654 PR-URL: #36665 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Daijiro Wachi <[email protected]> Reviewed-By: Yash Ladha <[email protected]>
Fixes: #36654 PR-URL: #36665 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Daijiro Wachi <[email protected]> Reviewed-By: Yash Ladha <[email protected]>
What steps will reproduce the bug?
Create a new
format.js
file with content below:Then run it with
node format.js
.How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior?
Should output
http://[::]
instead.What do you see instead?
It will output
http://[[::]]
which I believe is wrong.Additional information
url.format(urlobject)
was deprecated as per https://nodejs.org/api/url.html#url_url_format_urlobject, but there're still libraries using it.url.format(new URL('http://[::]'))
would outputhttp://[::]/
as I expected.The text was updated successfully, but these errors were encountered: