mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-16 11:37:37 +01:00
fix: #13939, dont append / if url is empty
dont call updateHistory twice on page load
This commit is contained in:
@@ -200,7 +200,7 @@ ajaxify.widgets = { render: render };
|
|||||||
if (window.history && window.history.pushState) {
|
if (window.history && window.history.pushState) {
|
||||||
window.history[!quiet ? 'pushState' : 'replaceState']({
|
window.history[!quiet ? 'pushState' : 'replaceState']({
|
||||||
url: url,
|
url: url,
|
||||||
}, url, config.relative_path + '/' + url);
|
}, '', config.relative_path + (url ? '/' + url : ''));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -557,10 +557,11 @@ ajaxify.widgets = { render: render };
|
|||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
window.addEventListener('popstate', (ev) => {
|
window.addEventListener('popstate', (ev) => {
|
||||||
if (ev !== null && ev.state) {
|
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({
|
window.history.replaceState({
|
||||||
url: ev.state.returnPath,
|
url: returnPath,
|
||||||
}, ev.state.returnPath, config.relative_path + '/' + ev.state.returnPath);
|
}, '', config.relative_path + (returnPath ? '/' + returnPath : ''));
|
||||||
} else if (ev.state.url !== undefined) {
|
} else if (ev.state.url !== undefined) {
|
||||||
ajaxify.handleTransientElements();
|
ajaxify.handleTransientElements();
|
||||||
ajaxify.go(ev.state.url, function () {
|
ajaxify.go(ev.state.url, function () {
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ define('messages', ['bootbox', 'translator', 'storage', 'alerts', 'hooks'], func
|
|||||||
|
|
||||||
function showQueryStringMessages() {
|
function showQueryStringMessages() {
|
||||||
const params = utils.params({ full: true });
|
const params = utils.params({ full: true });
|
||||||
|
const originalQs = params.toString();
|
||||||
showWelcomeMessage = params.has('loggedin');
|
showWelcomeMessage = params.has('loggedin');
|
||||||
registerMessage = params.get('register');
|
registerMessage = params.get('register');
|
||||||
|
|
||||||
@@ -102,7 +103,9 @@ define('messages', ['bootbox', 'translator', 'storage', 'alerts', 'hooks'], func
|
|||||||
}
|
}
|
||||||
|
|
||||||
const qs = params.toString();
|
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 () {
|
messages.showInvalidSession = function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user