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
This commit is contained in:
Gigi
2025-10-23 20:18:35 +02:00
parent 44a7e6ae2c
commit ed5decf3e9

View File

@@ -394,9 +394,22 @@ const Me: React.FC<MeProps> = ({
}
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<MeProps> = ({
}
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] || ''