diff --git a/godoc/static/playground.js b/godoc/static/playground.js index 51b00a43..e8242a08 100644 --- a/godoc/static/playground.js +++ b/godoc/static/playground.js @@ -118,7 +118,12 @@ function SocketTransport() { var id = 0; var outputs = {}; var started = {}; - var websocket = new WebSocket('ws://' + window.location.host + '/socket'); + var websocket; + if (window.location.protocol == "http:") { + websocket = new WebSocket('ws://' + window.location.host + '/socket'); + } else if (window.location.protocol == "https:") { + websocket = new WebSocket('wss://' + window.location.host + '/socket'); + } websocket.onclose = function() { console.log('websocket connection closed'); diff --git a/godoc/static/static.go b/godoc/static/static.go index 14739d80..d450f472 100644 --- a/godoc/static/static.go +++ b/godoc/static/static.go @@ -2314,7 +2314,12 @@ function SocketTransport() { var id = 0; var outputs = {}; var started = {}; - var websocket = new WebSocket('ws://' + window.location.host + '/socket'); + var websocket; + if (window.location.protocol == "http:") { + websocket = new WebSocket('ws://' + window.location.host + '/socket'); + } else if (window.location.protocol == "https:") { + websocket = new WebSocket('wss://' + window.location.host + '/socket'); + } websocket.onclose = function() { console.log('websocket connection closed');