Skip to content

assigning a hostname with port 80 to URL.host will not override the existing port  #20465

Description

@giltayar
  • 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/foo

The same bug applies to https with port 443.

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.whatwg-urlIssues and PRs related to the WHATWG URL implementation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions