Request matches when request paths has same suffix
See original GitHub issueDescribe the bug
If the suffix matches, a request is mocked with the value between the suffix and path param. This leads to me not being able to have
/users/1/somepath
and
/users/somepath
as both of these match. The temporary fix is to change the order of these, but that’s not really the correct answer to this.
Environment
Browser
msw: 0.21.3
nodejs: 13.14.0
npm: 6.14.4
To Reproduce
Steps to reproduce the behavior:
- Go to https://mswjs.io/docs/basics/request-matching
- Write
/user/:userId/endofpath
in Request handler URL and/user/0251e7ac/test/abc/endofpath
in Actual request URL - See that it matches the path between.
Expected behavior
It should not match
Screenshots
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Solved: Re: how to match regardless whether there is a tra...
I have an issue while defining a resource in my api proxy. I want to allow only POST requests if the path suffix...
Read more >Request Matching Logic
The general rule for matching request to endpoint definition is “take first endpoint that fully matches criteria”. This means that there can be...
Read more >Rest query working for all suffix inputs after matching path ...
I have configured REST with Camel. In that I have successfully get response from writen APIs. my problem is that given api works...
Read more >URL Matching with PathPattern in Spring MVC
We could leave the request path encoded via UrlPathHelper#urlDecode but then we can't use a prefix Servlet mapping because the servletPath ...
Read more >Strip part of a path prefix when routing - Questions
A root path like /my-service with strip_path set to true results in an upstream request with a path of / , and isn't...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @pkkummermo thanks for raising this 😃.
What you are saying is correct, thanks !!! I’ll fix in a while 😃.
The issue is causing by https://github.com/mswjs/node-match-path/blob/e1e0fac2c335629ac1dd345c297e76d5ea922c92/src/pathToRegExp.ts#L18-L20 because we are not removing
/
Thanks for letting me know. The fix will propagate in the next release of
msw
then.