From 348da29b099817b55ecb69103aa242a9ba18f828 Mon Sep 17 00:00:00 2001 From: Max Litruv Boonzaayer Date: Mon, 10 Feb 2025 14:43:11 +1100 Subject: [PATCH] Refactor URL slug handling in NavigationService for cleaner format --- index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index d3172d9..ccbb384 100644 --- a/index.js +++ b/index.js @@ -468,8 +468,8 @@ class NavigationService { setupEventListeners() { window.addEventListener('popstate', async () => { - const slug = new URLSearchParams(window.location.search).toString() - .replace(/^=/, '').replace(/^\?/, ''); + // Get slug without equal sign and question mark + const slug = window.location.search.replace(/^\?=?/, '').replace(/^=/, ''); const hash = window.location.hash; this.eventBus.emit('navigation:requested', { slug, hash }); }); @@ -479,7 +479,8 @@ class NavigationService { if (target) { e.preventDefault(); const slug = target.href.split('?').pop(); - history.pushState({ slug }, '', target.href); + // Use clean URL format without equal sign + history.pushState(null, '', `?${slug}`); this.eventBus.emit('navigation:requested', { slug }); } });