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

url.parse regression in 18.17+ #49330

Description

@Cherry

Version

v18.17.1

Platform

Microsoft Windows NT 10.0.19045.0 x64

Subsystem

No response

What steps will reproduce the bug?

18.17.1

url.parse("npm:postman-request@2.88.1-postman.33")
Uncaught TypeError [ERR_INVALID_URL]: Invalid URL
    at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
    at new NodeError (node:internal/errors:405:5)
    at Url.parse (node:url:445:17)
    at Object.urlParse [as parse] (node:url:167:13) {
  input: 'npm:postman-request@2.88.1-postman.33',
  code: 'ERR_INVALID_URL'
}

18.16.0

url.parse("npm:postman-request@2.88.1-postman.33")
Url {
  protocol: 'npm:',
  slashes: null,
  auth: 'postman-request',
  host: '2.88.1-postman.33',
  port: null,
  hostname: '2.88.1-postman.33',
  hash: null,
  search: null,
  query: null,
  pathname: null,
  path: null,
  href: 'npm:postman-request@2.88.1-postman.33'
}

What do you see instead?

18.17.1 throws a ERR_INVALID_URL TypeError instead of returning the URL object as per 18.16.0 and prior.

Additional information

This string seems to parse fine using new url('npm:postman-request@2.88.1-postman.33') in both 18.16.0 and 18.17.1.

In 18.17:

PARSES: npm:postman-request@2.88.1
PARSES: npm:postman-request@2.88.1-postman
PARSES: npm:postman-request@2.88.1-postman.
FAILS: npm:postman-request@2.88.1-postman.33
PARSES: schema:something@1.0.0
PARSES: schema:something@1.0.0-p
FAILS: schema:something@1.0.0-p.1

In 18.16, all parse fine.

Activity

  1. MattIPv4 commented on Aug 25, 2023

    @MattIPv4
    Member

    👀 Just noting that this does work with new url():

    Welcome to Node.js v18.17.1.
    Type ".help" for more information.
    > new url("npm:postman-request@2.88.1-postman.33")
    URL {
      href: 'npm:postman-request@2.88.1-postman.33',
      origin: 'null',
      protocol: 'npm:',
      username: '',
      password: '',
      host: '',
      hostname: '',
      port: '',
      pathname: 'postman-request@2.88.1-postman.33',
      search: '',
      searchParams: URLSearchParams {},
      hash: ''
    }
    

    url#parse is a deprecated stability-0 method: https://nodejs.org/dist/latest-v18.x/docs/api/url.html#urlparseurlstring-parsequerystring-slashesdenotehost

  2. MattIPv4 commented on Aug 25, 2023

    @MattIPv4
    Member

    If I had to guess, Ada 2.x is the cause of this? It was landed in 18.17.0: #48345

  3. Cherry commented on Aug 25, 2023

    @Cherry
    ContributorAuthor

    #45514 seems to be another similar issue from the past, though not as niche as this one.

    I've opened raineorshine/npm-check-updates#1319 with a library I use that broke due to this when used with npm aliases, so hopefully things will be fixed there. But I do worry if there's other older libraries in the ecosystem that might see impact here too.

  4. added
    duplicateIssues and PRs that are duplicates of other issues or PRs.
    urlIssues and PRs related to the legacy built-in url module.
    on Aug 26, 2023
  5. aduh95 commented on Aug 28, 2023

    @aduh95
    Contributor

    @anonrig you added duplicate Issues and PRs that are duplicates of other issues or PRs. , but you forgot to link to the original issue. Can you add the link and close this issue please? Or please remove the label if you added it by mistake.

  6. anonrig commented on Aug 28, 2023

    @anonrig
    Member

    This issue is fixed with #48873 and will be part of the next Node 18 release.

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

    duplicateIssues and PRs that are duplicates of other issues or PRs.urlIssues and PRs related to the legacy built-in url module.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions