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

feat!: use URLPattern for request matching #2209

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
chore: remove same-name params merge test
  • Loading branch information
kettanaito committed Aug 28, 2024

Verified

This commit was signed with the committer’s verified signature.
rgoldberg Ross Goldberg
commit 49a050f6bc0f10d838f7503a6921fb6c90fe3f15
37 changes: 0 additions & 37 deletions src/core/utils/matching/matchRequestUrl.test.ts
Original file line number Diff line number Diff line change
@@ -128,43 +128,6 @@ test('supports a leading wildcard and a path with wildcards and a multiple named
})
})

test('merges multiple same-named groups into an array of values', () => {
// Must match same-named groups in different URL components.
expect(
matchRequestUrl(
new URL('https://example.com/user/abc/bar'),
'https://:segment.com/user/:segment/bar',
),
).toEqual<Match>({
matches: true,
params: {
segment: ['example', 'abc'],
},
})

// Must match same-named groups in the same URL component.
expect(
matchRequestUrl(
new URL('https://example.com/user/abc/bar/def'),
'https://example.com/user/:segment/bar/:segment',
),
).toEqual<Match>({
matches: true,
params: {
/**
* @note URLPattern doesn't support multiple same-named groups
* within the same URL component, to begin with.
* @see https://github.com/whatwg/urlpattern/issues/226
*
* However, "path-to-regexp" does! So does Express, and so does MSW.
* But it "supports" it in a weird way. It doesn't throw but takes
* the latest value of the group and preceding values.
*/
segment: 'def',
},
})
})

test('decodes group matches', () => {
const url = 'http://example.com:5001/example'
expect(
Loading