html: check trailing slash on pathname for ws url

Fixes #100
This commit is contained in:
Shuanglei Tao
2018-05-06 13:45:19 +08:00
parent 9bc52a6123
commit 6a217d7388
2 changed files with 3 additions and 2 deletions

View File

@@ -171,7 +171,8 @@ function handleReceive(zsession) {
var terminalContainer = document.getElementById('terminal-container'),
httpsEnabled = window.location.protocol === 'https:',
url = (httpsEnabled ? 'wss://' : 'ws://') + window.location.host + window.location.pathname + 'ws',
url = (httpsEnabled ? 'wss://' : 'ws://') + window.location.host + window.location.pathname
+ (window.location.pathname.endsWith('/') ? '' : '/') + 'ws',
textDecoder = new TextDecoder(),
textEncoder = new TextEncoder(),
authToken = (typeof tty_auth_token !== 'undefined') ? tty_auth_token : null,