mirror of
https://github.com/dergigi/boris.git
synced 2026-01-19 14:54:30 +01:00
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:
@@ -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] || ''
|
||||
|
||||
Reference in New Issue
Block a user