Open kettanaito opened 4 months ago
This failing test:
FAIL src/core/utils/matching/matchRequestUrl.test.ts > merges multiple same-named groups into an array of values
TypeError: Failed to construct 'URLPattern': invalid pathname pattern '/user/:segment/bar/:segment'.
❯ new me node_modules/.pnpm/urlpattern-polyfill@9.0.0/node_modules/urlpattern-polyfill/dist/urlpattern.js:1:14389
❯ Module.matchRequestUrl src/core/utils/matching/matchRequestUrl.ts:96:19
Is caused by https://github.com/whatwg/urlpattern/issues/226.
This also significantly improves the test coverage for path matching in MSW.
This change does not intend to support
URLPattern
as the input. For now, we will use it as internal mechanism (thus a polyfill version). Once the API gains global browser support, we may consider shipping an input support.Changes to document
/:a/foo/:a
. Not a thing in the HTTP spec. They are supported bypath-to-regexp
butURLPattern
decided not to implement them and stick closer to the spec./foo
handler will not match a/foo/
request, and vice versa. I think MSW should respect thatURLPattern
behavior too to bring wider adoption of the API and be spec-compliant.Roadmap
/foo/:a/bar/:a
syntax throws inURLPattern
. https://github.com/whatwg/urlpattern/issues/226. Doesn't throw inpath-to-regexp
and current MSW. Don't want to make a breaking change out of this.URLPattern
doesn't.