diff --git a/src/client/client.test.ts b/src/client/client.test.ts index e01931a1..e9c91877 100644 --- a/src/client/client.test.ts +++ b/src/client/client.test.ts @@ -1079,9 +1079,10 @@ describe('WebSocket URL Protocol Translation with Query Parameters', () => { query: { id: '123', type: 'test', + tag: ['a', 'b'], }, }) - expect(webSocketMock).toHaveBeenCalledWith('ws://localhost/index?id=123&type=test') + expect(webSocketMock).toHaveBeenCalledWith('ws://localhost/index?id=123&type=test&tag=a&tag=b') }) it('Translates HTTPS to wss and includes query parameters', async () => { diff --git a/src/client/client.ts b/src/client/client.ts index a5c29602..acd0ddad 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -183,8 +183,16 @@ export const hc = >( 'ws' ) const targetUrl = new URL(webSocketUrl) - for (const key in opts.args[0]?.query) { - targetUrl.searchParams.set(key, opts.args[0].query[key]) + + const queryParams: Record | undefined = opts.args[0]?.query + if (queryParams) { + Object.entries(queryParams).forEach(([key, value]) => { + if (Array.isArray(value)) { + value.forEach((item) => targetUrl.searchParams.append(key, item)) + } else { + targetUrl.searchParams.set(key, value) + } + }) } return new WebSocket(targetUrl.toString())