aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-util
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-01-16 19:34:44 -0300
committerSebastian <sebasjm@gmail.com>2023-01-17 16:01:25 -0300
commit3cde52effc5bc1ec82285b52938bc024083c3278 (patch)
treea838647085e8294092f79a71dfdf38e5b2890082 /packages/taler-util
parent99d7cbae04d3f53c003b69b7e082c55489dba2ca (diff)
use URL api to stringify payto://
Diffstat (limited to 'packages/taler-util')
-rw-r--r--packages/taler-util/src/payto.ts11
1 files changed, 5 insertions, 6 deletions
diff --git a/packages/taler-util/src/payto.ts b/packages/taler-util/src/payto.ts
index 8eb0b88a8..1ac081a76 100644
--- a/packages/taler-util/src/payto.ts
+++ b/packages/taler-util/src/payto.ts
@@ -81,13 +81,12 @@ export function addPaytoQueryParams(
* @returns
*/
export function stringifyPaytoUri(p: PaytoUri): string {
- const url = `${paytoPfx}${p.targetType}/${p.targetPath}`;
+ const url = new URL(`${paytoPfx}${p.targetType}/${p.targetPath}`);
const paramList = !p.params ? [] : Object.entries(p.params);
- if (paramList.length > 0) {
- const search = paramList.map(([key, value]) => `${key}=${value}`).join("&");
- return `${url}?${search}`;
- }
- return url;
+ paramList.forEach(([key, value]) => {
+ url.searchParams.set(key, value)
+ })
+ return url.href;
}
/**