diff options
| author | 2026-04-04 03:41:43 +0700 | |
|---|---|---|
| committer | 2026-04-04 03:41:43 +0700 | |
| commit | 13428b467f752d9b53b39a3c8122998f1896ed1e (patch) | |
| tree | 120db7c5a2f411de3d00b038f073676e06148a26 /views/layouts | |
| parent | b1355436e96f2dfa777e843b53896d0bb71628e3 (diff) | |
| download | web-13428b467f752d9b53b39a3c8122998f1896ed1e.tar.gz web-13428b467f752d9b53b39a3c8122998f1896ed1e.zip | |
fix: remove leading slash in path with going up
format: remove redundant var specs
Diffstat (limited to 'views/layouts')
| -rw-r--r-- | views/layouts/general-page.html | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/views/layouts/general-page.html b/views/layouts/general-page.html index 527b9ae..b620566 100644 --- a/views/layouts/general-page.html +++ b/views/layouts/general-page.html @@ -32,7 +32,11 @@ <script> function changeUrl(path, toAppend = false) { const urlParams = new URLSearchParams(window.location.search); - const newPathname = location.pathname.endsWith('/') ? location.pathname.slice(0, -1) : location.pathname; + newPathname = location.pathname.endsWith('/') ? location.pathname.slice(0, -1) : location.pathname; + while (path.slice(-3) == '/..' && toAppend) { + newPathname = newPathname.replace(/\/[^\/]+$/, ''); + path = path.slice(0, -3); + } const newPath = toAppend ? `${newPathname}${path}` : `${path}`; history.pushState({}, '', `${newPath}${urlParams.entries.length == 0 ? '' : '?' + urlParams.toString()}`); @@ -192,7 +196,7 @@ sm:left-0 sm:flex-col sm:fixed sm:w-fit z-20 shadow-[0_0_1rem_black]"> <nav aria-label="Main navigation" class="text-[3rem] flex flex-row sm:flex-col gap-0 relative z-20"> - <a onclick="return changeUrl('/../', true);" href="./" id="sidebar-back-button" class="themed-button themed-button-sidebar w-fit h-fit hidden" draggable="false"> + <a onclick="return changeUrl('/..', true);" href="../" id="sidebar-back-button" class="themed-button themed-button-sidebar w-fit h-fit hidden" draggable="false"> <i class="fas fa-circle-left flex w-18 h-18 content-center text-center text-sidebar"></i> </a> <a onclick="return changeUrl('/{{ .Lang }}');" href="/{{ .Lang }}" id="sidebar-home-button" class="themed-button themed-button-sidebar w-fit h-fit hidden" draggable="false"> |