diff options
author | Javan Makhmali <javan@javan.us> | 2015-12-15 10:35:02 -0500 |
---|---|---|
committer | Javan Makhmali <javan@javan.us> | 2015-12-15 10:35:02 -0500 |
commit | 8625518725575de5524405b264d901b691fce066 (patch) | |
tree | 7045136d0463f870b715fed94b4889661d6dc267 /actioncable/lib | |
parent | a8db0328a5452130b87b568b66fbd125eb10d45d (diff) | |
download | rails-8625518725575de5524405b264d901b691fce066.tar.gz rails-8625518725575de5524405b264d901b691fce066.tar.bz2 rails-8625518725575de5524405b264d901b691fce066.zip |
Bring latest changes over from actioncable/master
Diffstat (limited to 'actioncable/lib')
-rw-r--r-- | actioncable/lib/assets/javascripts/cable.coffee.erb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/actioncable/lib/assets/javascripts/cable.coffee.erb b/actioncable/lib/assets/javascripts/cable.coffee.erb index 25a9fc79c2..a722f27ac1 100644 --- a/actioncable/lib/assets/javascripts/cable.coffee.erb +++ b/actioncable/lib/assets/javascripts/cable.coffee.erb @@ -5,8 +5,19 @@ INTERNAL: <%= ActionCable::INTERNAL.to_json %> createConsumer: (url = @getConfig("url")) -> - new Cable.Consumer url + new Cable.Consumer @createWebSocketURL(url) getConfig: (name) -> element = document.head.querySelector("meta[name='action-cable-#{name}']") element?.getAttribute("content") + + createWebSocketURL: (url) -> + if url and not /^wss?:/i.test(url) + a = document.createElement("a") + a.href = url + # Fix populating Location properties in IE. Otherwise, protocol will be blank. + a.href = a.href + a.protocol = a.protocol.replace("http", "ws") + a.href + else + url |