Using the wildcard token to try to match random ports doesn't work if preceded by a colon #2204
Open
4 tasks done
Labels
bug
Something isn't working
DX
scope:browser
Related to MSW running in a browser
scope:node
Related to MSW running in Node
Milestone
Prerequisites
Environment check
msw
versionNode.js version
v20.15.1
Reproduction repository
https://github.com/silvenon/repro/tree/msw-wildcard-port
Reproduction steps
The reproduction branch contains a project with two test, both of them are passing, but the the first one is set to fail using
test.fails
.In a situation where you have to match an unknown port, atttempt to match it in MSW with something like this:
Then attempt to fetch something from
localhost
endpoints with random ports:Current behavior
Currently the library for matching the endpoint,
path-to-regexp
, seems to detect this as the parameter:If I remove the colon it acts as expected.
Expected behavior
Regardless of whether the wildcard is used with or without colon it should achieve a similar result:
localhost:*
localhost*
I.e. for this use case it should work. Except that in the latter pattern I would expect the hostname to not only match
localhost
, but alsolocalhostable
etc., so I consider it to be a workaround rather than a solution.The text was updated successfully, but these errors were encountered: