Skip to content
Source
Sign inSign up

relayUrl.test.ts

23 lines772 Bytes

1import { describe, expect, it } from "vite-plus/test";
2​
3import { isSecureRelayUrl, normalizeSecureRelayUrl } from "./relayUrl.ts";
4​
5describe("normalizeSecureRelayUrl", () => {
6 it("normalizes secure relay origins", () => {
7 expect(normalizeSecureRelayUrl(" https://relay.example.test/// ")).toBe(
8 "https://relay.example.test",
9 );
10 expect(normalizeSecureRelayUrl("https://relay.example.test:8443/")).toBe(
11 "https://relay.example.test:8443",
12 );
13 });
14​
15 it.each([
16 "http://relay.example.test",
17 "https://user:password@relay.example.test",
18 "https://relay.example.test/path",
19 ])("rejects unsafe relay URL %s", (value) => {
20 expect(normalizeSecureRelayUrl(value)).toBeNull();
21 expect(isSecureRelayUrl(value)).toBe(false);
22 });
23});