Skip to content

Commit

Permalink
Fix raw LNURLs for DeeplinkManager and ClipboardManager
Browse files Browse the repository at this point in the history
  • Loading branch information
hsjoberg committed Feb 18, 2022
1 parent 66c8c58 commit 8135c52
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 5 additions & 4 deletions src/state/ClipboardManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const clipboardManager: IClipboardManagerModel = {
return;
}
text = text.toLowerCase();
// TODO remove lightning:
log.i("try", [text]);
actions.addToInvoiceCache(text);

Expand All @@ -71,14 +72,14 @@ export const clipboardManager: IClipboardManagerModel = {
actions.tryInvoice({ paymentRequest: text });
}
// If this is a non-bech32 LNURL (LUD-17)
else if (text.includes("lnurlp:") || text.includes("lnurlw:") || text.includes("lnurlc:")) {
else if (text.includes("lnurlp://") || text.includes("lnurlw://") || text.includes("lnurlc://")) {
log.d("lnurl non-bech32");
text = "https://" + text.substring(7).split(/[\s&]/)[0];
text = "https://" + text.substring(9).split(/[\s&]/)[0];
actions.tryLNUrl({ url: text });
}
else if (text.includes("keyauth:")) {
else if (text.includes("keyauth://")) {
log.d("lnurl non-bech32 keyauth");
text = "https://" + text.substring(8).split(/[\s&]/)[0];
text = "https://" + text.substring(10).split(/[\s&]/)[0];
actions.tryLNUrl({ url: text });
}
// If this is an LNURL
Expand Down
8 changes: 4 additions & 4 deletions src/state/DeeplinkManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ export const deeplinkManager: IDeeplinkManager = {
return await actions.tryInvoice({ paymentRequest: subject.split("?")[0] });
}
// If this is a non-bech32 LNURL (LUD-17)
else if (subject.startsWith("lnurlp") || subject.startsWith("lnurlw") || subject.startsWith("lnurlc")) {
subject = "https://" + subject.substring(7);
else if (subject.startsWith("lnurlp://") || subject.startsWith("lnurlw://") || subject.startsWith("lnurlc://")) {
subject = "https://" + subject.substring(9);
return await actions.tryLNUrl({ url: subject.split("?")[0] });
}
else if (subject.startsWith("keyauth")) {
subject = "https://" + subject.substring(8);
else if (subject.startsWith("keyauth://")) {
subject = "https://" + subject.substring(10);
return await actions.tryLNUrl({ url: subject.split("?")[0] });
}
// If this is an LNURL
Expand Down

1 comment on commit 8135c52

@vercel
Copy link

@vercel vercel bot commented on 8135c52 Feb 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.