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()
subscribeWebSocket: ->
secure = window.location.scheme == "https"
@websocket = new WebSocket("#{if secure then "wss" else "ws"}://#{window.location.host}/messages")
secure = window.location.protocol is "https:"
protocol = if secure then "wss" else "ws"
@websocket = new WebSocket("#{protocol}://#{window.location.host}/messages")
@websocket.onmessage = (event) =>
@addMessage $.parseJSON event.data