base url support index file

This commit is contained in:
Yuri Kuznetsov
2023-10-19 16:48:50 +03:00
parent 1298a8382d
commit 4fd125ddfc
4 changed files with 28 additions and 3 deletions
+1 -1
View File
@@ -62,7 +62,7 @@ let onTimeout;
* @property {boolean} [resolveWithXhr] To resolve with `XMLHttpRequest`.
*/
const baseUrl = window.location.origin + window.location.pathname;
const baseUrl = Espo.Utils.obtainBaseUrl();
// noinspection JSUnusedGlobalSymbols
/**
+1 -1
View File
@@ -1442,7 +1442,7 @@ class App {
files.push(file);
});
let baseUrl = window.location.origin + window.location.pathname;
let baseUrl = Espo.Utils.obtainBaseUrl();
let timestamp = this.loader.getCacheTimestamp();
let promiseList = files.map(file => {
+9 -1
View File
@@ -99,7 +99,15 @@
this._internalModuleMap = {};
this._isDeveloperMode = false;
this._baseUrl = window.location.origin + window.location.pathname;
let baseUrl = window.location.origin + window.location.pathname;
if (baseUrl.slice(-1) !== '/') {
baseUrl = window.location.pathname.includes('.') ?
baseUrl.slice(0, baseUrl.lastIndexOf('/')) + '/' :
baseUrl + '/';
}
this._baseUrl = baseUrl;
this._isDeveloperModeIsSet = false;
this._basePathIsSet = false;
+17
View File
@@ -662,6 +662,23 @@ Espo.Utils = {
generateId: function () {
return (Math.floor(Math.random() * 10000001)).toString()
},
/**
* Not to be used in custom code. Can be removed in future versions.
* @internal
* @return {string}
*/
obtainBaseUrl: function () {
let baseUrl = window.location.origin + window.location.pathname;
if (baseUrl.slice(-1) !== '/') {
baseUrl = window.location.pathname.includes('.') ?
baseUrl.slice(0, baseUrl.lastIndexOf('/')) + '/' :
baseUrl + '/';
}
return baseUrl;
}
};
const keyMap = {