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

URLs with no hostname not parsed properly in v1.5.0 #205

Closed
jonomuller opened this issue May 25, 2021 · 1 comment · Fixed by #208
Closed

URLs with no hostname not parsed properly in v1.5.0 #205

jonomuller opened this issue May 25, 2021 · 1 comment · Fixed by #208

Comments

@jonomuller
Copy link

Hi there, I'm using this library to parse URLs with a custom protocol like so:

my-custom-protocol:///path-to/image.jpg

The behaviour has changed in v1.5.0 so that part of the pathname is being treated as the host. I believe this is a bug and goes against the browser implementation of URL, which produces a similar output similar to v1.4.7 with the hostname unset. I think it's due to the change in regex match here.

Output in v1.4.7:

{
  slashes: true,
  protocol: 'my-custom-protocol:',
  hash: '',
  query: '',
  pathname: '/path-to/image.jpg',
  auth: '',
  host: '',
  port: '',
  hostname: '',
  password: '',
  username: '',
  origin: 'null',
  href: 'my-custom-protocol:///path-to/image.jpg'
}

Output in v1.5.0:

{
  slashes: true,
  protocol: 'my-custom-protocol:',
  hash: '',
  query: '',
  pathname: '/image.jpg',
  auth: '',
  host: 'path-to',
  port: '',
  hostname: 'path-to',
  password: '',
  username: '',
  origin: 'my-custom-protocol://path-to',
  href: 'my-custom-protocol://path-to/image.jpg'
}

Let me know if you need any more details. Thanks!

@lpinca
Copy link
Member

lpinca commented May 29, 2021

It seems similar to #203. I think we should do something similar to #204 for all non special schemes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants