Skip to content

Commit 348da29

Browse files
committed
Refactor URL slug handling in NavigationService for cleaner format
1 parent 9933bc5 commit 348da29

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,8 @@ class NavigationService {
468468

469469
setupEventListeners() {
470470
window.addEventListener('popstate', async () => {
471-
const slug = new URLSearchParams(window.location.search).toString()
472-
.replace(/^=/, '').replace(/^\?/, '');
471+
// Get slug without equal sign and question mark
472+
const slug = window.location.search.replace(/^\?=?/, '').replace(/^=/, '');
473473
const hash = window.location.hash;
474474
this.eventBus.emit('navigation:requested', { slug, hash });
475475
});
@@ -479,7 +479,8 @@ class NavigationService {
479479
if (target) {
480480
e.preventDefault();
481481
const slug = target.href.split('?').pop();
482-
history.pushState({ slug }, '', target.href);
482+
// Use clean URL format without equal sign
483+
history.pushState(null, '', `?${slug}`);
483484
this.eventBus.emit('navigation:requested', { slug });
484485
}
485486
});

0 commit comments

Comments
 (0)