Skip to content

Commit 2ff27cb

Browse files
authored
Stripping the trailing backslashes off the current path
Added a line to strip the trailing backslashes off the current pathname in order to always attain the correct tab name and also append the new tab that we're navigating to correctly
1 parent 03ab17d commit 2ff27cb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

components/IonTabs.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
2121
// we need relative path for the goto to function properly and to allow for relative tab definitions
2222
const { pathname } = $page.url;
23-
const pathSplit = pathname.split("/");
23+
const cleanedPath = pathname.replace(/\/+$/, ''); // Strip trailing slashes, so we can get the last part of the path correctly. (e.g. /pages/homepage/ -> /pages/homepage)
24+
const pathSplit = cleanedPath.split("/");
2425
let currentTabName = pathSplit[pathSplit.length - 1]; // we don't want to use at(-1) because of old browsers
25-
const relativePath = pathname.replace(currentTabName, "");
26+
let relativePath = cleanedPath.replace(currentTabName, "");
2627
2728
// we need to capture the router changes - to support a-href navigation and other stuff
2829
$: if ($navigating && $navigating.to) {

0 commit comments

Comments
 (0)