Skip to content
This repository has been archived by the owner on Jun 27, 2022. It is now read-only.

Does not work with urls that have a request content type extension and parameters #17

Closed
andrewswerlick-hmn opened this issue Jun 15, 2020 · 2 comments · Fixed by #18
Closed

Comments

@andrewswerlick-hmn
Copy link

I haven't tested this extensively, but I'm using this library via MSW and I think I've found a fairly common use case that is not supported. Specifically, this library will not handle a url like
/api/books/:bookId.json.

In manually inspecting this file https://github.com/mswjs/node-match-path/blob/master/src/pathToRegExp.ts, I believe the problem is that line 19 does not include a "." in the list of characters to terminate the parameter match.

I'll try to submit a pull request and appropriate tests in the next day or so, but figured I'd go ahead and report the issue.

@andrewswerlick-hmn
Copy link
Author

Note this can be easily worked around by using the undocumented fact that a regex with capture groups will result in those captures being a part of the msw req.params object

@kettanaito
Copy link
Member

Hey, @andrewswerlick-hmn. That's a great catch, the matching expression indeed doesn't account for file extensions. Huge thanks for submitting the pull request! I'll look at it tomorrow and we'll solve this issue together.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants