aboutsummaryrefslogtreecommitdiff
path: root/src/taleruri-test.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-10-02 14:21:31 +0530
committerFlorian Dold <florian.dold@gmail.com>2019-10-02 14:22:26 +0530
commit3f6d3d186bf6960951b16eb1ffac160c5d02195d (patch)
tree6f41c8ce0b93099b8b6768fdf7a404853975fd18 /src/taleruri-test.ts
parente3a5dbfe32c639cbb7666362ea233032cda4b18e (diff)
taler URI parsing
* add support for non-https taler://pay URIs * implement path prefix properly
Diffstat (limited to 'src/taleruri-test.ts')
-rw-r--r--src/taleruri-test.ts44
1 files changed, 42 insertions, 2 deletions
diff --git a/src/taleruri-test.ts b/src/taleruri-test.ts
index 8b5828b7f..bf4e9d493 100644
--- a/src/taleruri-test.ts
+++ b/src/taleruri-test.ts
@@ -86,7 +86,7 @@ test("taler pay url parsing: instance", (t) => {
t.fail();
return;
}
- t.is(r1.downloadUrl, "https://example.com/instances/myinst/public/proposal?order_id=myorder");
+ t.is(r1.downloadUrl, "https://example.com/public/instances/myinst/proposal?order_id=myorder");
});
@@ -97,7 +97,47 @@ test("taler pay url parsing: path prefix and instance", (t) => {
t.fail();
return;
}
- t.is(r1.downloadUrl, "https://example.com/mypfx/instances/myinst/public/proposal?order_id=myorder");
+ t.is(r1.downloadUrl, "https://example.com/mypfx/instances/myinst/proposal?order_id=myorder");
+});
+
+test("taler pay url parsing: complex path prefix", (t) => {
+ const url1 = "taler://pay/example.com/mypfx%2Fpublic/-/myorder";
+ const r1 = parsePayUri(url1);
+ if (!r1) {
+ t.fail();
+ return;
+ }
+ t.is(r1.downloadUrl, "https://example.com/mypfx/public/proposal?order_id=myorder");
+});
+
+test("taler pay url parsing: complex path prefix and instance", (t) => {
+ const url1 = "taler://pay/example.com/mypfx%2Fpublic/foo/myorder";
+ const r1 = parsePayUri(url1);
+ if (!r1) {
+ t.fail();
+ return;
+ }
+ t.is(r1.downloadUrl, "https://example.com/mypfx/public/instances/foo/proposal?order_id=myorder");
+});
+
+test("taler pay url parsing: non-https #1", (t) => {
+ const url1 = "taler://pay/example.com/-/-/myorder?insecure=1";
+ const r1 = parsePayUri(url1);
+ if (!r1) {
+ t.fail();
+ return;
+ }
+ t.is(r1.downloadUrl, "http://example.com/public/proposal?order_id=myorder");
+});
+
+test("taler pay url parsing: non-https #2", (t) => {
+ const url1 = "taler://pay/example.com/-/-/myorder?insecure=2";
+ const r1 = parsePayUri(url1);
+ if (!r1) {
+ t.fail();
+ return;
+ }
+ t.is(r1.downloadUrl, "https://example.com/public/proposal?order_id=myorder");
});