Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

url.parse regression in 18.17+ #49330

Closed
Cherry opened this issue Aug 25, 2023 · 5 comments
Closed

url.parse regression in 18.17+ #49330

Cherry opened this issue Aug 25, 2023 · 5 comments
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. url Issues and PRs related to the legacy built-in url module. v18.x Issues that can be reproduced on v18.x or PRs targeting the v18.x-staging branch.

Comments

@Cherry
Copy link

Cherry commented Aug 25, 2023

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.

@MattIPv4
Copy link
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

@MattIPv4
Copy link
Member

MattIPv4 commented Aug 25, 2023

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

@Cherry
Copy link
Author

Cherry commented Aug 25, 2023

#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.

@anonrig anonrig added duplicate Issues and PRs that are duplicates of other issues or PRs. url Issues and PRs related to the legacy built-in url module. labels Aug 26, 2023
@aduh95
Copy link
Contributor

aduh95 commented Aug 28, 2023

@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.

@anonrig
Copy link
Member

anonrig commented Aug 28, 2023

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

@anonrig anonrig added the v18.x Issues that can be reproduced on v18.x or PRs targeting the v18.x-staging branch. label Aug 28, 2023
@anonrig anonrig closed this as completed Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. url Issues and PRs related to the legacy built-in url module. v18.x Issues that can be reproduced on v18.x or PRs targeting the v18.x-staging branch.
Projects
None yet
Development

No branches or pull requests

4 participants