gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] 02/04: fix: reward URI parser and tests didn't take


From: gnunet
Subject: [taler-wallet-core] 02/04: fix: reward URI parser and tests didn't take into account the last '/'
Date: Mon, 05 Feb 2024 13:18:44 +0100

This is an automated email from the git hooks/post-receive script.

sebasjm pushed a commit to branch master
in repository wallet-core.

commit 83ff7de59b8a00b313ecb00f4c6150a37c38902f
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Sun Feb 4 18:35:28 2024 -0300

    fix: reward URI parser and tests didn't take into account the last '/'
---
 packages/taler-util/src/taleruri.test.ts | 4 ++--
 packages/taler-util/src/taleruri.ts      | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/packages/taler-util/src/taleruri.test.ts 
b/packages/taler-util/src/taleruri.test.ts
index 208beebbb..4ed97cec2 100644
--- a/packages/taler-util/src/taleruri.test.ts
+++ b/packages/taler-util/src/taleruri.test.ts
@@ -237,7 +237,7 @@ test("taler reward pickup uri", (t) => {
 });
 
 test("taler reward pickup uri with instance", (t) => {
-  const url1 = "taler://reward/merchant.example.com/instances/tipm/tipid";
+  const url1 = "taler://reward/merchant.example.com/instances/tipm/tipid/";
   const r1 = parseRewardUri(url1);
   if (!r1) {
     t.fail();
@@ -248,7 +248,7 @@ test("taler reward pickup uri with instance", (t) => {
 });
 
 test("taler reward pickup uri with instance and prefix", (t) => {
-  const url1 = "taler://reward/merchant.example.com/my/pfx/tipm/tipid";
+  const url1 = "taler://reward/merchant.example.com/my/pfx/tipm/tipid/";
   const r1 = parseRewardUri(url1);
   if (!r1) {
     t.fail();
diff --git a/packages/taler-util/src/taleruri.ts 
b/packages/taler-util/src/taleruri.ts
index 8f37dfe76..22846c7a4 100644
--- a/packages/taler-util/src/taleruri.ts
+++ b/packages/taler-util/src/taleruri.ts
@@ -438,8 +438,9 @@ export function parseRewardUri(s: string): RewardUriResult 
| undefined {
     return undefined;
   }
   const host = parts[0].toLowerCase();
-  const rewardId = parts[parts.length - 1];
-  const pathSegments = parts.slice(1, parts.length - 1);
+  const unused = parts[parts.length - 1];
+  const rewardId = parts[parts.length - 2];
+  const pathSegments = parts.slice(1, parts.length - 2);
   const hostAndSegments = [host, ...pathSegments].join("/");
   const merchantBaseUrl = canonicalizeBaseUrl(
     `${pi.innerProto}://${hostAndSegments}/`,

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]