fix: #13939, dont append / if url is empty

dont call updateHistory twice on page load
This commit is contained in:
Barış Soner Uşaklı
2026-01-30 10:46:13 -05:00
parent 8d6b6f6a59
commit 2dc49c8228
2 changed files with 9 additions and 5 deletions

View File

@@ -200,7 +200,7 @@ ajaxify.widgets = { render: render };
if (window.history && window.history.pushState) {
window.history[!quiet ? 'pushState' : 'replaceState']({
url: url,
}, url, config.relative_path + '/' + url);
}, '', config.relative_path + (url ? '/' + url : ''));
}
};
@@ -557,10 +557,11 @@ ajaxify.widgets = { render: render };
$(document).ready(function () {
window.addEventListener('popstate', (ev) => {
if (ev !== null && ev.state) {
if (ev.state.url === null && ev.state.returnPath !== undefined) {
const { returnPath } = ev.state;
if (ev.state.url === null && returnPath !== undefined) {
window.history.replaceState({
url: ev.state.returnPath,
}, ev.state.returnPath, config.relative_path + '/' + ev.state.returnPath);
url: returnPath,
}, '', config.relative_path + (returnPath ? '/' + returnPath : ''));
} else if (ev.state.url !== undefined) {
ajaxify.handleTransientElements();
ajaxify.go(ev.state.url, function () {

View File

@@ -74,6 +74,7 @@ define('messages', ['bootbox', 'translator', 'storage', 'alerts', 'hooks'], func
function showQueryStringMessages() {
const params = utils.params({ full: true });
const originalQs = params.toString();
showWelcomeMessage = params.has('loggedin');
registerMessage = params.get('register');
@@ -102,7 +103,9 @@ define('messages', ['bootbox', 'translator', 'storage', 'alerts', 'hooks'], func
}
const qs = params.toString();
ajaxify.updateHistory(ajaxify.currentPage + (qs ? `?${qs}` : '') + document.location.hash, true);
if (qs !== originalQs) {
ajaxify.updateHistory(ajaxify.currentPage + (qs ? `?${qs}` : '') + document.location.hash, true);
}
}
messages.showInvalidSession = function () {