- Version: 8.8.1, but also occurs in 10.0.0
- Platform: MacOS
- Subsystem: url
Overriding the host property with a host that has port 80, will not override the port.
Example:
const{URL}=require('url')constu=newURL('http://localhost:3000/foo')u.host='some-domain:80'console.log(u.href)// expected http://some-domain:80/foo, actual: http://some-domain:3000/foo // note that any other port besides 80 works correctly:constu2=newURL('http://localhost:3000/foo')u2.host='some-domain:801'console.log(u2.href)// http://some-domain:801/fooThe same bug applies to https with port 443.
Overriding the host property with a host that has port 80, will not override the port.
Example:
The same bug applies to
httpswith port 443.