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

Inherit protocol and endpoint when not specified. #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
socket.elm_web_socket = true;
}
catch(err)
Expand Down