We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 534ba2c commit 18ca136Copy full SHA for 18ca136
1 file changed
src/Native/WebSocket.js
@@ -1,12 +1,22 @@
1
var _elm_lang$websocket$Native_WebSocket = function() {
2
3
+function getProtocol(){ return location.protocol.match(/^https/) ? "wss" : "ws" }
4
+
5
+function getEndpointURL(uri)
6
+{
7
+ if(uri.charAt(0) !== "/"){ return uri; }
8
+ if(uri.charAt(1) === "/"){ return getProtocol() + ':' + uri; }
9
10
+ return getProtocol() + '://' + location.host + uri;
11
+}
12
13
function open(url, settings)
14
{
15
return _elm_lang$core$Native_Scheduler.nativeBinding(function(callback)
16
17
try
18
- var socket = new WebSocket(url);
19
+ var socket = new WebSocket(getEndpointURL(url));
20
socket.elm_web_socket = true;
21
}
22
catch(err)
0 commit comments