Skip to content

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

@Janpot

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with 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