aa231797af
- Domain feed page at /timeline/:domain fetches .well-known/nostr.json and queries events from domain users - NIP-05 domains are clickable in usernames throughout the app (Nip05Badge, NoteCard, PostDetailPage, etc.) - @_@domain.com renders as @domain.com (underscore prefix hidden) - Profile hover cards on avatars, usernames, and mentions across all components - Clicking avatar/banner on profile page opens image in gallery lightbox with safe-area support - NIP-05 verified users get clean profile URLs (e.g. /user@domain.com) instead of /npub1... - NIP19Page unified dispatcher handles NIP-19, NIP-05, and profile routing at /:param - Removed /u/:npub and /d/:domain routes in favor of root-level routing - CORS proxy fallback for NIP-05 resolution on non-CORS-compliant servers - Mobile top bar logo links to home - Safe area fixes for gallery lightbox, mobile drawer, and sheet close button
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
/**
|
|
* NIP-05 utility functions for formatting and parsing NIP-05 identifiers.
|
|
*/
|
|
|
|
/**
|
|
* Formats a NIP-05 identifier for display.
|
|
* - `_@domain.com` becomes `domain.com` (the `_@` prefix is the default/root user and shouldn't render)
|
|
* - `user@domain.com` stays as `user@domain.com`
|
|
*/
|
|
export function formatNip05Display(nip05: string): string {
|
|
if (nip05.startsWith('_@')) {
|
|
return nip05.slice(2);
|
|
}
|
|
return nip05;
|
|
}
|
|
|
|
/**
|
|
* Extracts the domain from a NIP-05 identifier.
|
|
* `user@domain.com` → `domain.com`
|
|
*/
|
|
export function getNip05Domain(nip05: string | undefined): string | undefined {
|
|
if (!nip05) return undefined;
|
|
const atIndex = nip05.indexOf('@');
|
|
if (atIndex === -1) return undefined;
|
|
return nip05.slice(atIndex + 1);
|
|
}
|
|
|
|
/**
|
|
* Extracts the username portion from a NIP-05 identifier.
|
|
* `user@domain.com` → `user`
|
|
* `_@domain.com` → `_`
|
|
*/
|
|
export function getNip05User(nip05: string): string {
|
|
const atIndex = nip05.indexOf('@');
|
|
if (atIndex === -1) return nip05;
|
|
return nip05.slice(0, atIndex);
|
|
}
|