make websocket connection work over both http and https
authorTaylor Richards <taylor@icculus.org>
Mon, 5 Mar 2018 05:24:02 +0000 (00:24 -0500)
committerTaylor Richards <taylor@icculus.org>
Mon, 5 Mar 2018 05:24:02 +0000 (00:24 -0500)
src/network/standalone.html

index 387f7be..e49265b 100644 (file)
@@ -5,7 +5,7 @@
 <title>FreeSpace Standalone</title>
 
 <script>
-var std = new WebSocket("ws://" + document.URL.substr(7).split('/')[0], "standalone");
+var std = new WebSocket((location.protocol === "https:" ? "wss" : "ws") + "://" + location.host, "standalone");
 
 try {
        std.onclose = function(event) {