aboutsummaryrefslogtreecommitdiff
path: root/src/helpers-test.ts
blob: 4aac5ebec216170d088926c9509987f3d4bbb9e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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();
});