Fix secure websocket protocol negotiation

Fixes #160
This commit is contained in:
Samuel Cochran 2015-01-17 16:41:51 +11:00
parent e76d367755
commit d3f083f8df

View File

@ -292,8 +292,9 @@ class MailCatcher
@subscribePoll() @subscribePoll()
subscribeWebSocket: -> subscribeWebSocket: ->
secure = window.location.scheme == "https" secure = window.location.protocol is "https:"
@websocket = new WebSocket("#{if secure then "wss" else "ws"}://#{window.location.host}/messages") protocol = if secure then "wss" else "ws"
@websocket = new WebSocket("#{protocol}://#{window.location.host}/messages")
@websocket.onmessage = (event) => @websocket.onmessage = (event) =>
@addMessage $.parseJSON event.data @addMessage $.parseJSON event.data