From fdad16202750ef3bf5102870d66edb9b8383a8d4 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 19 Jun 2024 10:17:19 -0300 Subject: parse x-taler-bank account when comparing --- .../src/components/modal/index.tsx | 32 +++++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'packages/merchant-backoffice-ui/src/components/modal') diff --git a/packages/merchant-backoffice-ui/src/components/modal/index.tsx b/packages/merchant-backoffice-ui/src/components/modal/index.tsx index ce0df75ca..ba32950b5 100644 --- a/packages/merchant-backoffice-ui/src/components/modal/index.tsx +++ b/packages/merchant-backoffice-ui/src/components/modal/index.tsx @@ -297,6 +297,28 @@ interface CompareAccountsModalProps { testPayto: PaytoUri; } +function getHostFromHostPath(s: string | undefined) { + if (!s) return undefined; + try { + const u = new URL(`https://${s}`); + const endpath = u.pathname.lastIndexOf("/"); + return u.origin + u.pathname.substring(0, endpath); + } catch (e) { + return undefined; + } +} + +function getAccountIdFromHostPath(s: string | undefined) { + if (!s) return undefined; + try { + const u = new URL(`https://${s}`); + const endpath = u.pathname.lastIndexOf("/"); + return u.pathname.substring(endpath + 1); + } catch (e) { + return undefined; + } +} + export function CompareAccountsModal({ onCancel, onConfirm, @@ -365,15 +387,17 @@ export function CompareAccountsModal({ Host - {formPayto?.targetPath ?? "--"} - {testPayto.targetPath} + {getHostFromHostPath(formPayto?.targetPath) ?? "--"} + {getHostFromHostPath(testPayto.targetPath)} Account id - {formPayto?.targetPath ?? "--"} - {testPayto.targetPath} + + {getAccountIdFromHostPath(formPayto?.targetPath) ?? "--"} + + {getAccountIdFromHostPath(testPayto.targetPath)} )} -- cgit v1.2.3