Sitelet https://github.com/nodejs/node/issues/10306
Skip to content

Invalid Url when domain contains between 4 and 9 digits #10306

Description

@Janpot
  • Version: v7.2.1
  • Platform: Darwin Jans-MacBook-Pro-2.local 16.3.0 Darwin Kernel Version 16.3.0: Thu Nov 17 20:23:58 PST 2016; root:xnu-3789.31.2~1/RELEASE_X86_64 x86_64
  • Subsystem: url

Executing:

const { URL } = require('url');
new URL('http://1234.com');
new URL('http://123456789.com');

all throw

TypeError: Invalid URL
    at Object.URL.binding.parse (internal/url.js:85:17)
    at new URL (internal/url.js:81:13)
    at repl:1:1
    at realRunInThisContextScript (vm.js:22:35)
    at sigintHandlersWrap (vm.js:98:12)
    at ContextifyScript.Script.runInThisContext (vm.js:24:12)
    at REPLServer.defaultEval (repl.js:346:29)
    at bound (domain.js:280:14)
    at REPLServer.runBound [as eval] (domain.js:293:12)
    at REPLServer.onLine (repl.js:545:10)

all following work without a problem:

const { URL } = require('url');
new URL('http://123.com');
new URL('http://1234567890.com');

The bug doesn't happen in the browser. It looks like it tries to parse an IP address or something?

Activity

  1. toasohcah commented on Dec 16, 2016

    @toasohcah

    Note that it affects every integer in the range [256, 999999999]:

    > new (require("url").URL)('http://255.com/')
    URL {
    > new (require("url").URL)('http://256.com/')
    TypeError: Invalid URL
    > new (require("url").URL)('http://999999999.com/')
    TypeError: Invalid URL
    > new (require("url").URL)('http://1000000000.com/')
    URL {
    
  2. added
    urlIssues and PRs related to the legacy built-in url module.
    confirmed-bugIssues and PRs for confirmed bugs.
    on Dec 16, 2016
  3. targos commented on Dec 16, 2016

    @targos
    Member

    It looks like it tries to parse an IP address or something?

    Correct. I'm working on a fix

  4. added
    whatwg-urlIssues and PRs related to the WHATWG URL implementation.
    on Jan 5, 2017
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.urlIssues and PRs related to the legacy built-in url module.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