React Native: handlers with parameters break completely
See original GitHub issueDescribe the bug
WIth React Native, using a REST handler that includes a parameter causes all network requests to fail.
Environment
msw: 0.34.0
nodejs: 16.3.0
npm: 7.16.0
react-native: 0.64.2
To Reproduce
Expected behavior
Mocked network requests to be handled.
Explanation
I’ve created several REST handlers that have been working really well. I’ve subsequently added a new one that has a parameter value in the URL, but this causes all handlers to fail. I’ve tracked the problem down to the getResponse function, in particular it fails trying to find a relevant handler with the error:
SyntaxError: Invalid RegExp: Quantifier has nothing to repeat
To verify it’s only broken in React Native, I’ve created a node test and have verified it is working correctly.
I’ve spent a little while trying to track it down but it has me stumped. If anyone has any any pointers or suggestions on what might be going wrong I’m happy to create a pull request, but at this point I’m lost!
It’s probably worth mentioning that paths with wildcards do work, so in this case:
http://localhost/path/:id
will fail
http://localhost/path/*
will work
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top GitHub Comments
Hmm, okay that’s weird. I’ve created a bare-bones repo to demonstrate the bug - and it’s working there just fine. I’m going to have to dig in a little harder to figure out what’s causing it to break in my actual app.
The issue is related to Hermes, and the way they handle regexes:
Solution: