Skip to content

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

Closed
@jonomuller

Description

@jonomuller

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions