feat: Enhance pubkey conversion to support nprofile format in ProfilePage (#117)

Co-authored-by: highperfocused <highperfocused@pm.me>
This commit is contained in:
mroxso
2025-05-23 21:50:34 +02:00
committed by GitHub
parent 8c2cbd2491
commit f12373f437
2 changed files with 78 additions and 2 deletions

View File

@@ -16,11 +16,18 @@ export default function ProfilePage() {
const params = useParams()
let pubkey = Array.isArray(params.pubkey) ? params.pubkey[0] : params.pubkey;
// check if pubkey contains "npub"
// if so, then we need to convert it to a pubkey
// check if pubkey contains "npub" or "nprofile"
// if so, we need to convert it to a hex pubkey
if (pubkey.includes("npub")) {
// convert npub to pubkey
pubkey = nip19.decode(pubkey.toString()).data.toString()
} else if (pubkey.includes("nprofile")) {
// convert nprofile to pubkey
const decoded = nip19.decode(pubkey.toString());
if (decoded.type === 'nprofile') {
const profileData = decoded.data as { pubkey: string; relays?: string[] };
pubkey = profileData.pubkey;
}
}
const npubShortened = useMemo(() => {