aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-10-31 10:08:25 -0700
committerAdam Soltys <[email protected]>2024-10-31 10:08:25 -0700
commitd63d502755fa71f9da04247500d78139fd61fbb9 (patch)
tree7ae4bc0ba782c147d7e021d934fa55e13659b3c4 /src/lib
parent243abb0a3d29e8e34e263eec843488e3bdb468a4 (diff)
downloadcoinos-ui-d63d502755fa71f9da04247500d78139fd61fbb9.tar.gz
coinos-ui-d63d502755fa71f9da04247500d78139fd61fbb9.zip
check invoice type
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/parse.ts21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/lib/parse.ts b/src/lib/parse.ts
index 6e38150c..fcce7e1e 100644
--- a/src/lib/parse.ts
+++ b/src/lib/parse.ts
@@ -10,8 +10,7 @@ export default async (t, host) => {
if (t.startsWith("http")) redirect(307, t);
if (t.startsWith(host)) redirect(307, `http://${t}`);
- let amount;
- let user;
+ let amount, user;
t = t.trim();
t.toLowerCase().startsWith("bitcoin:") &&
@@ -30,14 +29,6 @@ export default async (t, host) => {
if (t.includes("/fund")) redirect(307, t.substring(t.indexOf("/fund")));
- // invoice
- let invoice;
- try {
- invoice = await get(`/invoice/${t}`);
- } catch (e) {}
-
- if (invoice) redirect(307, `/send/invoice/${invoice.id}`);
-
// lightning
if (t.toLowerCase().startsWith("lightning:"))
t = t.toLowerCase().replace("lightning:", "");
@@ -55,7 +46,7 @@ export default async (t, host) => {
// bitcoin
if (validate(t) || isLiquid(t)) {
let r = `/send/bitcoin/${t}`;
- if (amount) r += `/${amount}`;
+ if (amount) r += "/" + amount;
redirect(307, r);
}
@@ -78,4 +69,12 @@ export default async (t, host) => {
} catch (e) {}
if (fund) redirect(307, `/send/fund/${t}`);
+
+ // invoice
+ let invoice;
+ try {
+ invoice = await get(`/invoice/${t}`);
+ } catch (e) {}
+
+ if (invoice) redirect(307, `/send/invoice/${invoice.id}`);
};