aboutsummaryrefslogtreecommitdiff
path: root/packages/merchant-backoffice-ui/src/components/modal
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-06-19 10:17:19 -0300
committerSebastian <sebasjm@gmail.com>2024-06-19 10:17:19 -0300
commitfdad16202750ef3bf5102870d66edb9b8383a8d4 (patch)
tree7793c1331e9a0f55a08dea190a86c39ed72e909e /packages/merchant-backoffice-ui/src/components/modal
parent3418a2fcb4b73374b5433052d05978cf9212093c (diff)
downloadwallet-core-fdad16202750ef3bf5102870d66edb9b8383a8d4.tar.xz
parse x-taler-bank account when comparing
Diffstat (limited to 'packages/merchant-backoffice-ui/src/components/modal')
-rw-r--r--packages/merchant-backoffice-ui/src/components/modal/index.tsx32
1 files changed, 28 insertions, 4 deletions
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({
<td>
<i18n.Translate>Host</i18n.Translate>
</td>
- <td>{formPayto?.targetPath ?? "--"}</td>
- <td>{testPayto.targetPath}</td>
+ <td>{getHostFromHostPath(formPayto?.targetPath) ?? "--"}</td>
+ <td>{getHostFromHostPath(testPayto.targetPath)}</td>
</tr>
<tr>
<td>
<i18n.Translate>Account id</i18n.Translate>
</td>
- <td>{formPayto?.targetPath ?? "--"}</td>
- <td>{testPayto.targetPath}</td>
+ <td>
+ {getAccountIdFromHostPath(formPayto?.targetPath) ?? "--"}
+ </td>
+ <td>{getAccountIdFromHostPath(testPayto.targetPath)}</td>
</tr>
</Fragment>
)}