Viewer respects the --urlRootLocation option

This commit is contained in:
Veloman Yunkan 2022-08-07 16:54:48 +04:00
parent 17ff2a094d
commit a9446714ea
1 changed files with 13 additions and 3 deletions

View File

@ -59,12 +59,20 @@
//
// iframe url: the URL to be loaded in the viewer iframe.
function getRootLocation() {
const p = location.pathname;
return p.slice(0, p.length - '/viewer'.length);
}
const root = getRootLocation();
const blankPageUrl = `${root}/skin/blank.html`;
function userUrl2IframeUrl(url) {
if ( url == '' ) {
return '/skin/blank.html';
return blankPageUrl;
}
return `/content/${url}`;
return `${root}/content/${url}`;
}
function getBookFromUserUrl(url) {
@ -125,10 +133,12 @@
}
function iframeUrl2UserUrl(url) {
if ( url == '/skin/blank.html' ) {
if ( url == blankPageUrl ) {
return '';
}
url = url.slice(root.length);
return url.split('/').slice(2).join('/');
}