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')

const u = new URL('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:

const u2 = new URL('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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for 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