From 234ed304c7c891a56bee00cd52e9d20a33602035 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Tue, 4 Mar 2025 08:19:49 -0800 Subject: [PATCH] Make lnurl parsing more robust --- packages/util/src/Profile.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/util/src/Profile.ts b/packages/util/src/Profile.ts index 74db99f..92970ef 100644 --- a/packages/util/src/Profile.ts +++ b/packages/util/src/Profile.ts @@ -26,10 +26,23 @@ export const isPublishedProfile = (profile: Profile): profile is PublishedProfil Boolean(profile.event) export const makeProfile = (profile: Partial = {}): Profile => { - const address = profile.lud06 || profile.lud16 - const lnurl = typeof address === "string" ? getLnUrl(address) : null + if (typeof profile.lud06 === "string") { + const lnurl = getLnUrl(profile.lud06) - return lnurl ? {lnurl, ...profile} : profile + if (lnurl) { + profile = {...profile, lnurl} + } + } + + if (typeof profile.lud16 === "string") { + const lnurl = getLnUrl(profile.lud16) + + if (lnurl) { + profile = {...profile, lnurl} + } + } + + return profile } export const readProfile = (event: TrustedEvent): PublishedProfile => ({