From 39035139130925bf596175ad8a3419a4cea401a8 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sun, 21 Jun 2020 18:19:27 +0530 Subject: implement manual withdrawal --- src/util/payto.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/util') 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("/"); -- cgit v1.2.3