refactor: centralize Nostr gateway URLs in config

- Create nostrGateways.ts config file with PRIMARY (njump.me) and SEARCH (search.dergigi.com) gateways
- Add helper functions: getProfileUrl, getEventUrl, getNostrUrl
- Update all hardcoded gateway URLs across the codebase to use the config
- Updated files: HighlightItem, nostrUriResolver, BookmarkViews (Card/Large), ResolvedMention
This commit is contained in:
Gigi
2025-10-13 00:05:11 +02:00
parent ee4d480961
commit 8fdf9938c2
6 changed files with 48 additions and 10 deletions

View File

@@ -1,4 +1,5 @@
import { decode, npubEncode, noteEncode } from 'nostr-tools/nip19'
import { getNostrUrl } from '../config/nostrGateways'
/**
* Regular expression to match nostr: URIs and bare NIP-19 identifiers
@@ -39,7 +40,7 @@ export function extractNaddrUris(text: string): string[] {
/**
* Decode a NIP-19 identifier and return a human-readable link
* For articles (naddr), returns an internal app link
* For other types, returns an external njump.me link
* For other types, returns an external gateway link
*/
export function createNostrLink(encoded: string): string {
try {
@@ -53,13 +54,13 @@ export function createNostrLink(encoded: string): string {
case 'nprofile':
case 'note':
case 'nevent':
return `https://njump.me/${encoded}`
return getNostrUrl(encoded)
default:
return `https://njump.me/${encoded}`
return getNostrUrl(encoded)
}
} catch (error) {
console.warn('Failed to decode nostr URI:', encoded, error)
return `https://njump.me/${encoded}`
return getNostrUrl(encoded)
}
}