1 |
|
2 |
|
3 | import { URL } from "../url";
|
4 |
|
5 | describe("Invalid URLs that should throw an Error", () => {
|
6 | test("Empty hosts should not allow special schemes (excluding file)", () => {
|
7 | expect(() => {
|
8 | let url = new URL("https://");
|
9 | }).toThrow();
|
10 |
|
11 |
|
12 | let fileUrl = new URL("file://");
|
13 | expect(fileUrl).toBeTruthy();
|
14 | });
|
15 |
|
16 | test("Opaque hosts should not allow special schemes (except http and https)", () => {
|
17 | expect(() => {
|
18 | let url = new URL("ftp://hello");
|
19 | }).toThrow();
|
20 |
|
21 | expect(() => {
|
22 | let url = new URL("http://localhost");
|
23 | }).toBeTruthy();
|
24 | });
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | test("Will throw on port edge cases", () => {
|
31 | expect(() => {
|
32 | let url = new URL("https://fastly.com:0");
|
33 | }).toThrow();
|
34 |
|
35 | expect(() => {
|
36 | let url = new URL("https://fastly.com:65536");
|
37 | }).toThrow();
|
38 | });
|
39 | });
|