From ed5decf3e93c31fa2e9f0cfa09144edc6652c970 Mon Sep 17 00:00:00 2001 From: Gigi Date: Thu, 23 Oct 2025 20:18:35 +0200 Subject: [PATCH] fix: properly route nostr-event URLs to /e/ path instead of /a/ - Add special handling for nostr-event: URLs in getReadItemUrl - Add special handling for nostr-event: URLs in handleSelectUrl - Prevent nostr-event URLs from being incorrectly routed to /a/ path (which expects naddr) - Route nostr-event URLs to /e/ path for proper event loading - Fixes 'String must be lowercase or uppercase' error when loading base64-encoded nostr-event URLs --- src/components/Me.tsx | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/components/Me.tsx b/src/components/Me.tsx index 9b992ed4..4edbae51 100644 --- a/src/components/Me.tsx +++ b/src/components/Me.tsx @@ -394,9 +394,22 @@ const Me: React.FC = ({ } const getReadItemUrl = (item: ReadItem) => { + // Handle nostr-event: URLs specially - route to /e/ path + const urlToCheck = item.url || item.id + if (urlToCheck?.startsWith('nostr-event:')) { + const eventId = urlToCheck.replace('nostr-event:', '') + return `/e/${eventId}` + } + if (item.type === 'article') { - // ID is already in naddr format - return `/a/${item.id}` + // Check if ID is actually an naddr + if (item.id.startsWith('naddr1')) { + return `/a/${item.id}` + } + // Fallback: if it has a URL, use /r/ path + if (item.url) { + return `/r/${encodeURIComponent(item.url)}` + } } else if (item.url) { return `/r/${encodeURIComponent(item.url)}` } @@ -437,6 +450,13 @@ const Me: React.FC = ({ } const handleSelectUrl = (url: string, bookmark?: { id: string; kind: number; tags: string[][]; pubkey: string }) => { + // Handle nostr-event: URLs specially - route to /e/ path + if (url?.startsWith('nostr-event:')) { + const eventId = url.replace('nostr-event:', '') + navigate(`/e/${eventId}`) + return + } + if (bookmark && bookmark.kind === 30023) { // For kind:30023 articles, navigate to the article route const dTag = bookmark.tags.find(t => t[0] === 'd')?.[1] || ''