From 5f5fe8e2f1eaf0172808a0f52abb576ec2baab8a Mon Sep 17 00:00:00 2001 From: Vladislav Zaynchkovsky Date: Tue, 5 Jun 2018 14:55:49 +0300 Subject: [PATCH 1/2] use socket relative to page path --- .gitignore | 1 + app/ui.js | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index c178dbab..7bc521aa 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ recordings *.swp *~ noVNC-*.tgz +.idea/ \ No newline at end of file diff --git a/app/ui.js b/app/ui.js index d587cfc6..70131788 100644 --- a/app/ui.js +++ b/app/ui.js @@ -161,7 +161,9 @@ const UI = { UI.initSetting('resize', 'off'); UI.initSetting('shared', true); UI.initSetting('view_only', false); - UI.initSetting('path', 'websockify'); + + let socketUrl = (window.location.pathname || '').replace(/\/[\w\.]+$/, '/websockify'); + UI.initSetting('path', socketUrl || '/websockify'); UI.initSetting('repeaterID', ''); UI.initSetting('reconnect', false); UI.initSetting('reconnect_delay', 5000); @@ -1012,7 +1014,7 @@ const UI = { if(port) { url += ':' + port; } - url += '/' + path; + url += path; UI.rfb = new RFB(document.getElementById('noVNC_container'), url, { shared: UI.getSetting('shared'), From 01692ec3a57fb7be983659f59c5e6d84234be403 Mon Sep 17 00:00:00 2001 From: Vladislav Zaynchkovsky Date: Thu, 7 Jun 2018 15:12:48 +0300 Subject: [PATCH 2/2] update regex to cover more cases --- app/ui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/ui.js b/app/ui.js index 70131788..6817cd3c 100644 --- a/app/ui.js +++ b/app/ui.js @@ -162,7 +162,7 @@ const UI = { UI.initSetting('shared', true); UI.initSetting('view_only', false); - let socketUrl = (window.location.pathname || '').replace(/\/[\w\.]+$/, '/websockify'); + let socketUrl = (window.location.pathname || '/').replace(/\/([^/]+)?$/, '/websockify'); UI.initSetting('path', socketUrl || '/websockify'); UI.initSetting('repeaterID', ''); UI.initSetting('reconnect', false);