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

Unexpected pathname match on trailing slash in actual URL #131

Open
kettanaito opened this issue Jul 17, 2024 · 0 comments
Open

Unexpected pathname match on trailing slash in actual URL #131

kettanaito opened this issue Jul 17, 2024 · 0 comments

Comments

@kettanaito
Copy link

kettanaito commented Jul 17, 2024

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.

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

No branches or pull requests

1 participant