From 6861dc1d57c8c9822a1b86a1e251643b6b8e8293 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 20 May 2024 12:49:01 -0500 Subject: [PATCH] Fix crash parsing Lightning URL Fixes https://gitlab.com/soapbox-pub/ditto/-/issues/139 --- src/utils/lnurl.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/utils/lnurl.ts b/src/utils/lnurl.ts index ea5ce8a..af344f2 100644 --- a/src/utils/lnurl.ts +++ b/src/utils/lnurl.ts @@ -28,8 +28,12 @@ function getLnurl({ lud06, lud16 }: { lud06?: string; lud16?: string }, limit?: if (lud16) { const [name, host] = lud16.split('@'); if (name && host) { - const url = new URL(`/.well-known/lnurlp/${name}`, `https://${host}`); - return LNURL.encode(url, limit); + try { + const url = new URL(`/.well-known/lnurlp/${name}`, `https://${host}`); + return LNURL.encode(url, limit); + } catch { + return; + } } } }