Skip to content

Commit

Permalink
Remove double braces from the ws url when using raw IPv6 address
Browse files Browse the repository at this point in the history
  • Loading branch information
ilkkao committed Dec 29, 2020
1 parent ca9e45d commit 0ddb128
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion client-src/default/utils/createSocketUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,21 @@ function getSocketUrl(urlParts, loc) {
// all of these sock url params are optionally passed in through
// resourceQuery, so we need to fall back to the default if
// they are not provided
const host = query.host || hostname;
let host = query.host || hostname;
const path = query.path || '/ws';
let portOption = query.port || port;

if (portOption === 'location') {
portOption = loc.port;
}

// In case the host is a raw IPv6 address, it can be enclosed in
// the brackets as the brackets are needed in the final URL string.
// Need to remove those as url.format blindly adds its own set of bracket
// if the host string contains colons. That would lead to non-working
// double brace (e.g. [[::]]) host
host = host.replace(/^\[(.*)\]$/, '$1');

return url.format({
protocol,
auth,
Expand Down

0 comments on commit 0ddb128

Please sign in to comment.