Skip to content

Remove double brackets from the ws url when using raw IPv6 address #2951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 brackets
// if the host string contains colons. That would lead to non-working
// double brackets (e.g. [[::]]) host
host = typeof host === 'string' ? host.replace(/^\[(.*)\]$/, '$1') : host;

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