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

Optional path parameters do not match correctly #2168

Closed
1 task
GeorgeToka opened this issue May 24, 2024 · 4 comments · Fixed by #2169
Closed
1 task

Optional path parameters do not match correctly #2168

GeorgeToka opened this issue May 24, 2024 · 4 comments · Fixed by #2169
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@GeorgeToka
Copy link

Scope

Improves an existing behavior

Compatibility

  • This is a breaking change

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 kettanaito added bug Something isn't working and removed feature labels May 25, 2024
@kettanaito
Copy link
Member

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
Copy link
Member

I've added an automated test for this in #2169, and it seems to be failing, which is good! More investigation required.

@kettanaito kettanaito changed the title Optional URL parameters are not working Does not match paths with optional parameters May 25, 2024
@kettanaito kettanaito added help wanted Extra attention is needed good first issue Good for newcomers labels May 25, 2024
@kettanaito kettanaito changed the title Does not match paths with optional parameters Optional path parameters do not match correctly May 25, 2024
KaiSpencer added a commit to KaiSpencer/msw that referenced this issue May 25, 2024
@kettanaito
Copy link
Member

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
Copy link
Author

@kettanaito Thanks for the quick turnaround on this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants