use URL api to stringify payto://
This commit is contained in:
parent
99d7cbae04
commit
3cde52effc
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user