fix(desktop): validate gateway WebSocket URLs

This commit is contained in:
ethernet 2026-07-22 14:31:53 -04:00
parent 9160f10fc9
commit 02fa447f8e
2 changed files with 24 additions and 2 deletions

View file

@ -43,6 +43,12 @@ describe('JsonRpcGatewayClient connect() URL guard', () => {
)
})
it('rejects a malformed ws URL before opening a socket', async () => {
const client = new JsonRpcGatewayClient()
await expect(client.connect('ws://')).rejects.toThrow(/requires a ws:\/\/ or wss:\/\/ URL string/)
expect(client.connectionState).toBe('idle')
})
it('keeps connection state idle on rejection', async () => {
const client = new JsonRpcGatewayClient()
await client.connect(undefined as unknown as string).catch(() => undefined)