Replies: 2 comments 1 reply
-
Want to say that I love this library so far and I'm willing to contribute a fix if we agree it's a problem. |
Beta Was this translation helpful? Give feedback.
-
Hey, @Murderlon. Thanks for raising this. MSW uses a path-to-regexp package, which is also used by Express and acts as a foundation for a new var { match } = require("path-to-regexp")
const fn = match('/foo:bar')
fn('/foosome') // params: { bar: "some" } That being said, I find this behavior to be correct. Although they are often referred to as "path" parameters, these dynamic segments can be present anywhere in the URL string. For instance, you can parametrize your hostname in a similar fashion:
So I can't agree that path parameters should apply only when preceded by a slash. |
Beta Was this translation helpful? Give feedback.
-
Prerequisites
Environment check
msw
versionBrowsers
Firefox
Reproduction repository
https://codesandbox.io/s/eloquent-panna-n2duee?file=/src/mocks/handlers.js
Reproduction steps
See the codesandbox.
Routes should only be dynamic params if a slash is immediately followed by a colon (
/:foo/bar
, not/foo:bar/baz
)Current behavior
In the codesandbox I request the second handler but it resolves with weird params to the first.
Expected behavior
Only have dynamic params if a slash is immediately followed by a colon
Beta Was this translation helpful? Give feedback.
All reactions