Skip to content

Commit

Permalink
Use location.port when location.hostname is used as a fallback in client
Browse files Browse the repository at this point in the history
  • Loading branch information
rlamana committed Feb 27, 2019
1 parent cb10f83 commit 5ecf099
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion client-src/default/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ const onSocketMsg = {

let hostname = urlParts.hostname;
let protocol = urlParts.protocol;
let port = urlParts.port;

// check ipv4 and ipv6 `all hostname`
if (hostname === '0.0.0.0' || hostname === '::') {
Expand All @@ -190,6 +191,7 @@ if (hostname === '0.0.0.0' || hostname === '::') {
// eslint-disable-next-line no-bitwise
if (self.location.hostname && !!~self.location.protocol.indexOf('http')) {
hostname = self.location.hostname;
port = self.location.port;
}
}

Expand All @@ -208,7 +210,7 @@ const socketUrl = url.format({
protocol,
auth: urlParts.auth,
hostname,
port: urlParts.port,
port,
// If sockPath is provided it'll be passed in via the __resourceQuery as a
// query param so it has to be parsed out of the querystring in order for the
// client to open the socket to the correct location.
Expand Down

0 comments on commit 5ecf099

Please sign in to comment.