From e2e07e147b6241851ed32b9065ef4096ad54cedf Mon Sep 17 00:00:00 2001 From: ryanlovett Date: Mon, 30 Apr 2018 15:51:29 -0700 Subject: [PATCH] Don't use landing page in websocket path. --- app/ui.js | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/app/ui.js b/app/ui.js index 78decb5d..ed950ff5 100644 --- a/app/ui.js +++ b/app/ui.js @@ -156,17 +156,38 @@ var UI = { } } + /* + * If novnc is hosted at PATHNAME, the default ws path should be at WS: + * PATHNAME WS + * / /websockify + * /foo/myvnc /foo/myvnc/websockify + * /foo/myvnc/ + * /foo/myvnc/vnc.html + * /foo/myvnc/vnc_lite.html + */ var path = 'websockify'; + var landing_pages = ['vnc.html', 'vnc_lite.html']; // If noVNC is not being served at the root path, prefix // the default websocket path with the server path. var pathName = window.location.pathname.slice(1); if (pathName.length != 0) { // We are not at the root path if (pathName.slice(-1) == '/') { // There's a trailing slash. - path = pathName + 'websockify'; + path = pathName + path; } else { - // There's no trailing slash. - path = pathName + '/websockify'; + // If there is no trailing slash, we may not be at a directory. + var pathElements = pathName.split('/'); + var pathLast = pathElements.pop(); + + // If we are at one of our landing pages, rewind to its parent + // directory. Otherwise we assume we are already in a directory. + for (var i=0; i