Use shortened URL in pushState

Earlier we were using the full URL, now only query string is passed in pushState, much cleaner!
This commit is contained in:
Nikhil Tanwar
2022-06-24 15:53:26 +05:30
committed by Veloman Yunkan
parent 947744caea
commit 37b39430d1
2 changed files with 4 additions and 4 deletions

View File

@ -282,7 +282,7 @@
kiwixHomeBody.setAttribute('style', 'display: flex; justify-content: center; align-items: center');
divTag.getElementsByTagName('a')[0].onclick = (event) => {
event.preventDefault();
window.history.pushState({}, null, `${window.location.href.split('?')[0]}?lang=`);
window.history.pushState({}, null, `?lang=`);
setCookie(filterCookieName, 'lang=');
resetAndFilter();
document.querySelectorAll('.filter').forEach(filter => {
@ -355,7 +355,7 @@
params = new URLSearchParams(window.location.search);
if (filterType) {
params.set(filterType, filterValue);
window.history.pushState({}, null, `${window.location.href.split('?')[0]}?${params.toString()}`);
window.history.pushState({}, null, `?${params.toString()}`);
setCookie(filterCookieName, params.toString());
}
updateFilterColors();
@ -429,7 +429,7 @@
filter.addEventListener('change', () => {resetAndFilter(filter.name, filter.value)});
});
if (filters) {
window.history.pushState({}, null, `${window.location.href.split('?')[0]}?${params.toString()}`);
window.history.pushState({}, null, `?${params.toString()}`);
}
updateVisibleParams();
document.getElementById('kiwixSearchForm').onsubmit = (event) => {event.preventDefault()};