The function `webSocketUrl` should not depend on global state. Please change it to accept `search` as a parameter.

You should set the query string via `a.search` instead of appending the query string to href.