Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

favicon.test.ts

42 lines1.3 KB

1import { describe, expect, it } from "vite-plus/test";
2​
3import { faviconUrlForOrigin } from "./favicon";
4​
5describe("faviconUrlForOrigin", () => {
6 it("never sends private origin hostnames to the public provider", () => {
7 for (const url of [
8 "http://localhost:3000/",
9 "http://127.0.0.1:3000/",
10 "http://0.0.0.0:3000/",
11 "http://devbox:3000/",
12 "https://24x.xf.local/",
13 "http://printer.home.arpa/",
14 "http://192.168.1.20:3000/",
15 "http://[::]/",
16 "http://[::ffff:192.168.1.20]/",
17 "http://100.65.180.100:3000/",
18 "https://devbox.example.ts.net/",
19 "http://192.0.2.1/",
20 "http://198.51.100.1/",
21 "http://203.0.113.1/",
22 "http://224.0.0.1/",
23 "http://240.0.0.1/",
24 "http://[2001:db8::1]/",
25 "http://[ff02::1]/",
26 "http://app.test../",
27 "https://24x.xf.local../",
28 "http://printer.home.arpa../",
29 "https://devbox.example.ts.net../",
30 "http://127.0.0.1../",
31 "http://127.1../",
32 "http://10.1../",
33 "http://172.16.1../",
34 "http://192.168.1../",
35 ]) {
36 expect(faviconUrlForOrigin(url)).toBeNull();
37 }
38 expect(faviconUrlForOrigin("https://example.com/path", 32)).toBe(
39 "https://www.google.com/s2/favicons?domain=example.com&sz=32",
40 );
41 });
42});