mswjs / msw

Industry standard API mocking for JavaScript.
https://mswjs.io
MIT License
16k stars 522 forks source link

Optional path parameters do not match correctly #2168

Closed GeorgeToka closed 5 months ago

GeorgeToka commented 6 months ago

Scope

Improves an existing behavior

Compatibility

Feature description

There is a step that drops query parameters and it looks like it breaks the ability to specify optional URL parameters, e.g /api/user/:id?.

The cleanup routine should be limited to removing the query parameters only.

kettanaito commented 6 months ago

Hi, @GeorgeToka. Thanks for reporting this!

The cleanUrl function you are referencing is applied to the actual request URL. That one cannot have path parameter annotations, only the literal values of those parameters.

But the issue you are describing is possible, the root cause may just be in a different place. We need an automated test to prove that.

kettanaito commented 6 months ago

I've added an automated test for this in https://github.com/mswjs/msw/pull/2169, and it seems to be failing, which is good! More investigation required.

kettanaito commented 5 months ago

Released: v2.3.1 🎉

This has been released in v2.3.1!

Make sure to always update to the latest version (npm i msw@latest) to get the newest features and bug fixes.


Predictable release automation by @ossjs/release.

GeorgeToka commented 5 months ago

@kettanaito Thanks for the quick turnaround on this one.