Skip to content

Commit

Permalink
Use websocket via HTTPS if appropriate
Browse files Browse the repository at this point in the history
If the page was loaded via HTTPS, the websocket should also connect via HTTPS.
  • Loading branch information
andrenarchy committed Jan 27, 2015
1 parent f2d91f5 commit 1e5ebe6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/mopidy.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ Mopidy.prototype._getConsole = function (settings) {
Mopidy.prototype._configure = function (settings) {
var currentHost = (typeof document !== "undefined" &&
document.location.host) || "localhost";
var protocol = (typeof document !== "undefined" &&
document.location.protocol === "https:") ? "wss://" : "ws://";
settings.webSocketUrl = settings.webSocketUrl ||
"ws://" + currentHost + "/mopidy/ws";
protocol + currentHost + "/mopidy/ws";

if (settings.autoConnect !== false) {
settings.autoConnect = true;
Expand Down

0 comments on commit 1e5ebe6

Please sign in to comment.