From 4e80d59c1ce3fda8e9bb0e89580be04ba5866c2b Mon Sep 17 00:00:00 2001 From: codytseng Date: Sun, 22 Jun 2025 12:57:43 +0800 Subject: [PATCH] feat: redirect bech32 paths --- src/PageManager.tsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/PageManager.tsx b/src/PageManager.tsx index e13fd554..d010e7eb 100644 --- a/src/PageManager.tsx +++ b/src/PageManager.tsx @@ -95,6 +95,23 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) { useEffect(() => { const hasHistoryState = !!history.state + if (['/npub1', '/nprofile1'].some((prefix) => window.location.pathname.startsWith(prefix))) { + window.history.replaceState( + null, + '', + '/users' + window.location.pathname + window.location.search + window.location.hash + ) + } else if ( + ['/note1', '/nevent1', '/naddr1'].some((prefix) => + window.location.pathname.startsWith(prefix) + ) + ) { + window.history.replaceState( + null, + '', + '/notes' + window.location.pathname + window.location.search + window.location.hash + ) + } window.history.pushState(null, '', window.location.href) if (window.location.pathname !== '/') { if (