Skip to content
This repository has been archived by the owner on May 5, 2020. It is now read-only.

Commit

Permalink
Inherit protocol and endpoint when not specified.
Browse files Browse the repository at this point in the history
  • Loading branch information
edevil committed Jul 7, 2016
1 parent deb5b75 commit a23087d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Native/WebSocket.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
var _elm_lang$websocket$Native_WebSocket = function() {

function getProtocol(){ return location.protocol.match(/^https/) ? "wss" : "ws" }

function getEndpointURL(uri)
{
if(uri.charAt(0) !== "/"){ return uri; }
if(uri.charAt(1) === "/"){ return getProtocol() + ':' + uri; }

return getProtocol() + '://' + location.host + uri;
}

function open(url, settings)
{
return _elm_lang$core$Native_Scheduler.nativeBinding(function(callback)
{
try
{
var socket = new WebSocket(url);
var socket = new WebSocket(getEndpointURL(url));
}
catch(err)
{
Expand Down

0 comments on commit a23087d

Please sign in to comment.