taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit bfee7a72ba94904fbd3cc936a65add99bc261cbe
parent 443f1e0d74e31a8c728123f103fae401ff9b92ae
Author: Sebastian <sebasjm@gmail.com>
Date:   Fri, 23 May 2025 15:13:05 -0300

fix #10000

Diffstat:
Mpackages/merchant-backoffice-ui/src/components/form/InputPaytoForm.tsx | 36+++++++++++++++++++++++++++---------
1 file changed, 27 insertions(+), 9 deletions(-)

diff --git a/packages/merchant-backoffice-ui/src/components/form/InputPaytoForm.tsx b/packages/merchant-backoffice-ui/src/components/form/InputPaytoForm.tsx @@ -103,9 +103,9 @@ function validateEthereum_path1( /** * validates "[host]:[port]/[path]/" where: * host: can be localhost, bank.com - * port: any number + * port: any number * path: may include subpath - * + * * for example * localhost * bank.com/ @@ -248,13 +248,19 @@ export function InputPaytoForm<T>({ path1: !value.path1 ? i18n.str`Required` : value.target === "iban" - ? validateIBAN_path1(value.path1, i18n) + ? validateIBAN_path1(cleanupPath1(value.path1, value.target), i18n) : value.target === "bitcoin" - ? validateBitcoin_path1(value.path1, i18n) + ? validateBitcoin_path1(cleanupPath1(value.path1, value.target), i18n) : value.target === "ethereum" - ? validateEthereum_path1(value.path1, i18n) + ? validateEthereum_path1( + cleanupPath1(value.path1, value.target), + i18n, + ) : value.target === "x-taler-bank" - ? validateTalerBank_path1(value.path1, i18n) + ? validateTalerBank_path1( + cleanupPath1(value.path1, value.target), + i18n, + ) : undefined, path2: value.target === "x-taler-bank" @@ -271,8 +277,9 @@ export function InputPaytoForm<T>({ const hasErrors = errors !== undefined; - const path1WithSlash = - value.path1 && !value.path1.endsWith("/") ? value.path1 + "/" : value.path1; + const path1WithSlash = !value.path1 + ? undefined + : cleanupPath1(value.path1, value.target); const pto = hasErrors || !value.target ? undefined @@ -280,7 +287,7 @@ export function InputPaytoForm<T>({ targetType: value.target, targetPath: value.path2 ? `${path1WithSlash}${value.path2}` - : value.path1 ?? "", + : path1WithSlash ?? "", params: value.params ?? {}, isKnown: false as const, } as PaytoUri); @@ -445,3 +452,14 @@ export function InputPaytoForm<T>({ </InputGroup> ); } +function cleanupPath1(str: string, type?: string) { + if (type === "iban") { + // we tolerate country in any case + // and don't care about any space + return str.replace(/\s/g, '').toUpperCase(); + } + if (type === "x-taler-bank") { + return !str.endsWith("/") ? str + "/" : str; + } + return str; +}