Fix crash parsing Lightning URL

Fixes https://gitlab.com/soapbox-pub/ditto/-/issues/139
This commit is contained in:
Alex Gleason 2024-05-20 12:49:01 -05:00
parent 78b9c62af3
commit 6861dc1d57
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 6 additions and 2 deletions

View File

@ -28,8 +28,12 @@ function getLnurl({ lud06, lud16 }: { lud06?: string; lud16?: string }, limit?:
if (lud16) { if (lud16) {
const [name, host] = lud16.split('@'); const [name, host] = lud16.split('@');
if (name && host) { if (name && host) {
try {
const url = new URL(`/.well-known/lnurlp/${name}`, `https://${host}`); const url = new URL(`/.well-known/lnurlp/${name}`, `https://${host}`);
return LNURL.encode(url, limit); return LNURL.encode(url, limit);
} catch {
return;
}
} }
} }
} }