aboutsummaryrefslogtreecommitdiff
path: root/src/helpers-test.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-11-14 01:29:08 +0100
committerFlorian Dold <florian.dold@gmail.com>2016-11-14 01:29:08 +0100
commit4df35bdcd9e57452bb7f5f5b73f9e52f3693a78f (patch)
tree6b135fe557438b7d77aa4f6400c1f4686c43fdd6 /src/helpers-test.ts
parent3d79aba854ccdbc79e8b7145ca99d6e0803e66bc (diff)
downloadwallet-core-4df35bdcd9e57452bb7f5f5b73f9e52f3693a78f.tar.xz
add test for base url canonicalization and fix canonicalization bug
Diffstat (limited to 'src/helpers-test.ts')
-rw-r--r--src/helpers-test.ts21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/helpers-test.ts b/src/helpers-test.ts
new file mode 100644
index 000000000..4aac5ebec
--- /dev/null
+++ b/src/helpers-test.ts
@@ -0,0 +1,21 @@
+import {test, TestLib} from "testlib/talertest";
+import * as helpers from "./helpers";
+
+
+test("URL canonicalization", (t: TestLib) => {
+ // converts to relative, adds https
+ t.assertEqualsStrict(
+ "https://alice.example.com/exchange/",
+ helpers.canonicalizeBaseUrl("alice.example.com/exchange"))
+
+ // keeps http, adds trailing slash
+ t.assertEqualsStrict(
+ "http://alice.example.com/exchange/",
+ helpers.canonicalizeBaseUrl("http://alice.example.com/exchange"))
+
+ // keeps http, adds trailing slash
+ t.assertEqualsStrict(
+ "http://alice.example.com/exchange/",
+ helpers.canonicalizeBaseUrl("http://alice.example.com/exchange#foobar"))
+ t.pass();
+});