diff options
| author | 2025-08-31 18:15:15 +0700 | |
|---|---|---|
| committer | 2025-08-31 18:15:15 +0700 | |
| commit | f174579ef53fb726594a2f7064299b86c8691ea3 (patch) | |
| tree | 21bd53317b366ead826d1f90a3d17daf6e7ac666 /views | |
| parent | 145e7e05f3aa6adbc71a0db5e7da160e626bacd3 (diff) | |
| download | web-f174579ef53fb726594a2f7064299b86c8691ea3.tar.gz web-f174579ef53fb726594a2f7064299b86c8691ea3.zip | |
fix: don't put question mark in url if no params
Diffstat (limited to 'views')
| -rw-r--r-- | views/layouts/general-page.html | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/views/layouts/general-page.html b/views/layouts/general-page.html index e9a6c0f..410e6e7 100644 --- a/views/layouts/general-page.html +++ b/views/layouts/general-page.html @@ -19,10 +19,10 @@ <script> function changeUrl(path, toAppend = false) { - const urlParams = new URLSearchParams(window.location.search); + const urlParams = new URLSearchParams(window.location.search); const newPathname = location.pathname.endsWith('/') ? location.pathname.slice(0, -1) : location.pathname; const newPath = toAppend ? `${newPathname}${path}` : `${path}`; - history.pushState({}, '', `${newPath}?${urlParams.toString()}`); + history.pushState({}, '', `${newPath}${urlParams.entries.length == 0 ? '' : '?' + urlParams.toString()}`); window.dispatchEvent(new Event('popstate')); }; </script> |