Skip to content

Commit 9af301a

Browse files
psjostromkettanaito
andauthoredMar 21, 2024··
fix: feature "new URL()" in the redundant query params warning (#2102)
Co-authored-by: Artem Zakharchenko <kettanaito@gmail.com>
1 parent 30bc5ac commit 9af301a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed
 

‎src/core/handlers/HttpHandler.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export class HttpHandler extends RequestHandler<
102102
})
103103

104104
devUtils.warn(
105-
`Found a redundant usage of query parameters in the request handler URL for "${method} ${path}". Please match against a path instead and access query parameters in the response resolver function using "req.url.searchParams".`,
105+
`Found a redundant usage of query parameters in the request handler URL for "${method} ${path}". Please match against a path instead and access query parameters using "new URL(request.url).searchParams" instead. Learn more: https://mswjs.io/docs/recipes/query-parameters`,
106106
)
107107
}
108108

‎test/browser/rest-api/query-params-warning.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ test('warns when a request handler URL contains query parameters', async ({
99
await loadExample(require.resolve('./query-params-warning.mocks.ts'))
1010

1111
expect(consoleSpy.get('warning')).toEqual([
12-
`[MSW] Found a redundant usage of query parameters in the request handler URL for "GET /user?name=admin". Please match against a path instead and access query parameters in the response resolver function using "req.url.searchParams".`,
13-
`[MSW] Found a redundant usage of query parameters in the request handler URL for "POST /login?id=123&type=auth". Please match against a path instead and access query parameters in the response resolver function using "req.url.searchParams".`,
12+
`[MSW] Found a redundant usage of query parameters in the request handler URL for "GET /user?name=admin". Please match against a path instead and access query parameters using \"new URL(request.url).searchParams\" instead. Learn more: https://mswjs.io/docs/recipes/query-parameters`,
13+
`[MSW] Found a redundant usage of query parameters in the request handler URL for "POST /login?id=123&type=auth". Please match against a path instead and access query parameters using \"new URL(request.url).searchParams\" instead. Learn more: https://mswjs.io/docs/recipes/query-parameters`,
1414
])
1515

1616
await fetch('/user?name=admin').then(async (res) => {

0 commit comments

Comments
 (0)
Please sign in to comment.