use URL api to stringify payto://
This commit is contained in:
parent
99d7cbae04
commit
3cde52effc
@ -81,13 +81,12 @@ export function addPaytoQueryParams(
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function stringifyPaytoUri(p: PaytoUri): string {
|
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);
|
const paramList = !p.params ? [] : Object.entries(p.params);
|
||||||
if (paramList.length > 0) {
|
paramList.forEach(([key, value]) => {
|
||||||
const search = paramList.map(([key, value]) => `${key}=${value}`).join("&");
|
url.searchParams.set(key, value)
|
||||||
return `${url}?${search}`;
|
})
|
||||||
}
|
return url.href;
|
||||||
return url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user