Skip to content

Unexpected pathname match on trailing slash in actual URL #131

@kettanaito

Description

@kettanaito

Steps to reproduce

"urlpattern-polyfill": "^10.0.0"
import { URLPattern } from 'urlpattern-polyfill'

let p = new URLPattern('https://example.com')
p.exec('https://example.com/')

Expected result

I expect the pattern to:

  1. Match.
  2. Have no entries in the groups through the entire match result.

Actual result

The pattern does match, but it incorrectly reports the trailing slash "/" as a group match for the pathname segment:

{
  inputs: [ 'https://example.com/' ],
  protocol: { input: 'https', groups: {} },
  username: { input: '', groups: { '0': '' } },
  password: { input: '', groups: { '0': '' } },
  hostname: { input: 'example.com', groups: {} },
  port: { input: '', groups: {} },
+ pathname: { input: '/', groups: { '0': '/' } },
  search: { input: '', groups: { '0': '' } },
  hash: { input: '', groups: { '0': '' } }
}

Since I haven't declared any matching groups there (i.e. wildcards or parameters), I don't expect to get any match results.

Additional info

This is reproducible on v10, not reproducible on v9.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions