Skip to content

Commit

Permalink
Use secure web socket connection for HTTPS host connections
Browse files Browse the repository at this point in the history
  • Loading branch information
rsms committed Mar 13, 2017
1 parent c77cf4e commit cb1ff20
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion js/gotalk.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions js/gotalk.js.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/gotalk.js.map

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions js/gotalk/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,9 @@ function openWebSocket(s, addr, callback) {
if (global.gotalkResponderAt !== undefined) {
var at = global.gotalkResponderAt;
if (at && at.ws) {
gotalk.defaultResponderAddress = 'ws://' + document.location.host + at.ws;
gotalk.defaultResponderAddress =
(document.location.protocol == 'https:' ? 'wss://' : 'ws://') +
document.location.host + at.ws;
}
delete global.gotalkResponderAt;
}
Expand All @@ -586,11 +588,7 @@ Sock.prototype.open = function(addr, callback) {
addr = gotalk.defaultResponderAddress;
}

if (addr.substr(0,3) === 'ws:') {
openWebSocket(s, addr, callback);
} else {
throw new Error('unsupported address');
}
openWebSocket(s, addr, callback);
return s;
};

Expand Down

0 comments on commit cb1ff20

Please sign in to comment.