From e38cde98aeaad31431995bd2d039c732bd22fd09 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Tue, 21 Feb 2023 14:48:32 +0100 Subject: [PATCH] fix parsing of lightning: prefix --- templates/cashu/wallet.html | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/templates/cashu/wallet.html b/templates/cashu/wallet.html index f2769df9a..93925b912 100644 --- a/templates/cashu/wallet.html +++ b/templates/cashu/wallet.html @@ -1631,13 +1631,14 @@ page_container %} // get request from pay invoice dialog req = this.payInvoiceData.data.request } - + // strip off lightning: prefix + if (req.toLowerCase().startsWith('lightning:')) { + req = req.slice(10) + } + // determine request type if (req.toLowerCase().startsWith('lnbc')) { this.payInvoiceData.data.request = req reqtype = 'bolt11' - } else if (req.toLowerCase().startsWith('lightning:')) { - this.payInvoiceData.data.request = req.slice(10) - reqtype = 'bolt11' } else if (req.toLowerCase().startsWith('lnurl:')) { this.payInvoiceData.data.request = req.slice(6) reqtype = 'lnurl' @@ -1652,8 +1653,12 @@ page_container %} ) { this.payInvoiceData.data.request = req reqtype = 'lnurl' - } else if (req.indexOf('eyJwcm')) { - // very dirty way of parsing cashu tokens from either a pasted token or a URL like https://host.com?token=eyJwcm + } else if ( + req.toLowerCase().startsWith('cashu:') || + req.indexOf('eyJwcm') != -1 + ) { + // very dirty way of parsing cashu tokens from either a pasted token or a URL like https://host.com?token=eyJwcm... + // or cashu:eyJwcm... this.receiveData.tokensBase64 = req.slice(req.indexOf('eyJwcm')) reqtype = 'cashu' }