Skip to content

URL parser inconsistency. #11707

Description

@DylanPiercey
  • Version: 7.6.0
  • Platform: macOS
  • Subsystem: url

Currently url is having some issues parsing odd hostnames like so:

new URL('http://.test.com').hostname // -> '0.0.0.9'

Where as in safari, chrome, the native url module and everywhere else this would be parsed as '.test.com'.

Activity

  1. added
    whatwg-urlIssues and PRs related to the WHATWG URL implementation.
    on Mar 6, 2017
  2. TimothyGu commented on Mar 6, 2017

    @TimothyGu
    Member

    Thanks for reporting! This has been fixed in #11549, which enables stricter parsing of hostnames as specified by the WHATWG URL Standard. The patch should be released in the next v7.x.

  3. TimothyGu commented on Mar 6, 2017

    @TimothyGu
    Member

    One thing to note is that while most browsers seem to accept the URL, #11549 actually throws an error on such cases:

    > new url.URL('http://.test.com').hostname
    TypeError: Invalid URL
        at URL.onParseComplete (internal/url.js:87:11)
        at parse (internal/url.js:110:11)
        at new URL (internal/url.js:211:5)
        at repl:1:1
    

    That is, again, in compliance with the URL Standard.

  4. DylanPiercey commented on Mar 10, 2017

    @DylanPiercey
    Author

    @TimothyGu thanks for that I had no idea.

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

    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