aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-06-21 18:19:27 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-06-21 18:19:27 +0530
commit39035139130925bf596175ad8a3419a4cea401a8 (patch)
tree0181b085abd76d60279ed709e53d07d413dd62a3 /src/util
parentc60b10ac827b564f999c401c013b55e123de3b5f (diff)
implement manual withdrawal
Diffstat (limited to 'src/util')
-rw-r--r--src/util/payto.ts19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/util/payto.ts b/src/util/payto.ts
index ac5bc0c7f..0f624de67 100644
--- a/src/util/payto.ts
+++ b/src/util/payto.ts
@@ -20,13 +20,26 @@ interface PaytoUri {
params: { [name: string]: string };
}
+const paytoPfx = "payto://";
+
+/**
+ * Add query parameters to a payto URI
+ */
+export function addPaytoQueryParams(s: string, params: { [name: string]: string }): string {
+ const [acct, search] = s.slice(paytoPfx.length).split("?");
+ const searchParams = new URLSearchParams(search || "");
+ for (let k of Object.keys(params)) {
+ searchParams.set(k, params[k]);
+ }
+ return paytoPfx + acct + "?" + searchParams.toString();
+}
+
export function parsePaytoUri(s: string): PaytoUri | undefined {
- const pfx = "payto://";
- if (!s.startsWith(pfx)) {
+ if (!s.startsWith(paytoPfx)) {
return undefined;
}
- const [acct, search] = s.slice(pfx.length).split("?");
+ const [acct, search] = s.slice(paytoPfx.length).split("?");
const firstSlashPos = acct.indexOf("/");