-
-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using wildcard/parameters in baseUrl in toHandlers method #267
Comments
Hey, @timkolotov. I think this should be fixed on the library's side. The data/src/model/generateRestHandlers.ts Lines 32 to 37 in 5be9ca3
From the look of it, I don't see any implications of supporting that. Would you be interested in opening a pull request with this feature? |
Yeah, will do. Probably this weekend. |
@kettanaito hey, I created a PR for this. It seems I can't request a review for it, so just FYI 🙂 |
Thanks, @timkolotov! Not sure what's with the review request permissions but I will look into it regardless. |
I recently started using MSW for both jest and storybook tests.
In our project, we use relative paths for the API, so the resulting URL depends on the environment the call is made. E.g. if storybook is run on
http://127.0.0.1:6006/
this host will be used in the API call. But it can also be run onhttp://localhost:6006/
So in MSW handlers, I used baseUrl with parameters such as
http://:hostname/:lang/api/v1/
and it works perfectly. Now I wanted to reduce the amount of boilerplate and addmswjs/data
with automatic generation of handles, but it seems to be not possible anymore as the URL constructor increateUrlBuilder
fails to parse such a string as that is not a valid URL.Is there any other way for manipulating the resulting paths in handlers, like just adding prefixes? Or the only way is to manually add all handlers?
The text was updated successfully, but these errors were encountered: