Parameter matching in routes fails with underscores
See original GitHub issueEnvironment
Name | Version |
---|---|
msw | 0.21.2 |
node | 10.16.3 |
OS | Windows 10 |
Request handlers
// Example of declaration. Provide your code here.
import { setupServer } from 'msw/node'
import { rest } from 'msw'
const server = setupServer(
rest.get('/project/project_id', () => {
// handle request
})
)
server.listen()
Actual request
fetch('/project/4').then((res) => res.json())
Current behavior
Request fails to match.
Expected behavior
Request should be matched by msw.
Note switching the URL parameter name to be projectId
results in the matching working as expected.
I could not see any restrictions on variable naming in the documentation hence raising the issue as it took quite a while to figure out why the request was not being matched and don’t want others to fall into the same trap.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Underscore in URL not working with attribute routing
When I request /SiteCode, it works fine. When I include a parameter, such as /SiteCode/something, that too works fine. When the URL is...
Read more >Regular Expressions
Pattern matching either succeeds or fails. For example, you can specify in an X.25 routing table that incoming packets with destination addresses beginning ......
Read more >Regular Expressions :: Eloquent JavaScript
This problem occurs when a pattern can match a piece of input in many different ways. For example, if we get confused while...
Read more >Bash Reference Manual - GNU.org
A word consisting solely of letters, numbers, and underscores, ... The first pattern that matches determines the command-list that is ...
Read more >PEP 622 – Structural Pattern Matching
The wildcard pattern is a single underscore: _ . It always matches, but does not capture ... During failed pattern matches, some sub-patterns...
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
Thanks to @timdeschryver the issue has been fixed and published in
node-match-path@0.5.1
. If you re-install your dependencies the fix should propagate in.@joe-hilling, absolutely no worries! I’m already thankful for you finding and reporting this, you rock!
@timdeschryver, thanks for volunteering to battle this issue! I’ve created a task in the
node-match-path
repo (https://github.com/mswjs/node-match-path/issues/26). Would love to support you in this contribution. Looking forward to see the pull request!