From fa484dc03d24ce6df1dec266dbde85bfd78ddf7f Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 6 Mar 2026 21:32:35 -0600 Subject: [PATCH] Use /r/* wildcard route for relay pages, supporting bare URLs with slashes --- src/AppRouter.tsx | 2 +- src/components/NoteContent.tsx | 2 +- src/pages/RelayPage.tsx | 20 ++++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/AppRouter.tsx b/src/AppRouter.tsx index fa4e1ac8..b47b7a9b 100644 --- a/src/AppRouter.tsx +++ b/src/AppRouter.tsx @@ -107,7 +107,7 @@ export function AppRouter() { } /> } /> } /> - } /> + } /> } /> {/* NIP-19 route for npub1, note1, naddr1, nevent1, nprofile1 */} diff --git a/src/components/NoteContent.tsx b/src/components/NoteContent.tsx index bfd423e8..dea83282 100644 --- a/src/components/NoteContent.tsx +++ b/src/components/NoteContent.tsx @@ -635,7 +635,7 @@ export function NoteContent({ return ( e.stopPropagation()} > diff --git a/src/pages/RelayPage.tsx b/src/pages/RelayPage.tsx index 5addadd2..84f21532 100644 --- a/src/pages/RelayPage.tsx +++ b/src/pages/RelayPage.tsx @@ -86,22 +86,22 @@ function useRelayFeed(relayUrl: string | undefined, kinds: number[]) { export function RelayPage() { const { config } = useAppContext(); - const { '*': urlParam } = useParams(); + const { '*': rawParam } = useParams(); const { feedSettings } = useFeedSettings(); const { muteItems } = useMuteList(); const kinds = getEnabledFeedKinds(feedSettings).filter((k) => !isRepostKind(k)); - // Reconstruct the relay URL from the wildcard param + // Support both encoded URLs (/r/wss%3A%2F%2F...) and bare URLs (/r/wss://...). const relayUrl = useMemo(() => { - if (!urlParam) return undefined; - // If the param already has a protocol, use it as-is - if (urlParam.startsWith('wss://') || urlParam.startsWith('ws://')) { - return urlParam; + if (!rawParam) return undefined; + // If the wildcard param has no "://", it's encoded — decode it. + const url = rawParam.includes('://') ? rawParam : decodeURIComponent(rawParam); + if (url.startsWith('wss://') || url.startsWith('ws://')) { + return url; } - // Otherwise, prepend wss:// - return `wss://${urlParam}`; - }, [urlParam]); + return `wss://${url}`; + }, [rawParam]); // Derive a display hostname from the URL const hostname = useMemo(() => { @@ -130,7 +130,7 @@ export function RelayPage() { description: info?.description ?? `Events from ${hostname}`, }); - if (!urlParam) { + if (!rawParam) { return ; }