Skip to content

Commit 2ec8160

Browse files
authored
fix: remove double brackets from the ws url when using raw IPv6 address (#2951)
1 parent 3ac015b commit 2ec8160

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

client-src/default/utils/createSocketUrl.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,21 @@ function getSocketUrl(urlParts, loc) {
7272
// all of these sock url params are optionally passed in through
7373
// resourceQuery, so we need to fall back to the default if
7474
// they are not provided
75-
const host = query.host || hostname;
75+
let host = query.host || hostname;
7676
const path = query.path || '/ws';
7777
let portOption = query.port || port;
7878

7979
if (portOption === 'location') {
8080
portOption = loc.port;
8181
}
8282

83+
// In case the host is a raw IPv6 address, it can be enclosed in
84+
// the brackets as the brackets are needed in the final URL string.
85+
// Need to remove those as url.format blindly adds its own set of brackets
86+
// if the host string contains colons. That would lead to non-working
87+
// double brackets (e.g. [[::]]) host
88+
host = typeof host === 'string' ? host.replace(/^\[(.*)\]$/, '$1') : host;
89+
8390
return url.format({
8491
protocol,
8592
auth,

0 commit comments

Comments
 (0)