fix: preserve search params in "onUnhandledRequest" messages#2128
fix: preserve search params in "onUnhandledRequest" messages#2128kettanaito merged 3 commits intomswjs:mainfrom
Conversation
…ve url in warning message
|
|
||
| const urlInstance = url instanceof URL ? url : new URL(url) | ||
|
|
||
| const [, relativeUrl] = urlInstance.href.split(urlInstance.origin) |
There was a problem hiding this comment.
This does solve the problem but it changes the other use cases we have for toPublicUrl.
I think a far better approach is to keep these changes scoped to the immediate problem area: the toPublic() usage in the onUnhandledRequest.ts.
msw/src/core/utils/request/onUnhandledRequest.ts
Lines 24 to 27 in e83a669
Let's try something like this:
const url = new URL(request.url)
const publicUrl = toPublicUrl(url) + url.searchThis way both relative and absolute URLs will be printed correctly but will also have any search parameters preserved.
Then, we can modify the tests in onUnhandledRequest.test.ts to include two new scenarios:
- Unhandled request with a relative URL and search params;
- Unhandled request with an absolute URL and search params.
There was a problem hiding this comment.
Thanks for the suggestion. Made changes now and pushed to PR again.
kettanaito
left a comment
There was a problem hiding this comment.
Thanks for tackling this, @nagadevkrishna! I left a suggestion, let me know what you think about it.
|
awesome! |
|
Don't close it just yet. I need to merge it so it gets to MSW. Be patient. |
|
Welcome to the contributors, @nagadevkrishna! 👏 |
Released: v2.2.14 🎉This has been released in v2.2.14! Make sure to always update to the latest version ( Predictable release automation by @ossjs/release. |
Uh oh!
There was an error while loading. Please reload this page.