The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 03:37 UTC
| 1 | import { describe, expect, it } from "@effect/vitest"; |
| 2 | |
| 3 | import { faviconUrlForOrigin, toolActivityFaviconUrl } from "./favicon.ts"; |
| 4 | |
| 5 | describe("faviconUrlForOrigin", () => { |
| 6 | it("sends only the public hostname and requested size, never the port", () => { |
| 7 | expect(faviconUrlForOrigin("https://github.com:8443/pingdotgg/t3code?private=query", 64)).toBe( |
| 8 | "https://www.google.com/s2/favicons?domain=github.com&sz=64", |
| 9 | ); |
| 10 | }); |
| 11 | |
| 12 | // regression: #5838 no favicon request for missing or non-http origins |
| 13 | it.each([null, "invalid URL", "file:///tmp/private"])( |
| 14 | "rejects an invalid or unsupported origin %s", |
| 15 | (origin) => { |
| 16 | expect(faviconUrlForOrigin(origin)).toBeNull(); |
| 17 | }, |
| 18 | ); |
| 19 | }); |
| 20 | |
| 21 | describe("toolActivityFaviconUrl", () => { |
| 22 | it("uses the page origin instead of a third-party favicon service", () => { |
| 23 | expect(toolActivityFaviconUrl({ pageUrl: "https://example.com/docs/page?q=1" }, "light")).toBe( |
| 24 | "https://example.com/favicon.ico", |
| 25 | ); |
| 26 | expect(toolActivityFaviconUrl({ pageUrl: "http://localhost:5173/app" }, "light")).toBe( |
| 27 | "http://localhost:5173/favicon.ico", |
| 28 | ); |
| 29 | }); |
| 30 | |
| 31 | it("accepts provider-supplied image URLs but rejects extension URLs", () => { |
| 32 | expect( |
| 33 | toolActivityFaviconUrl( |
| 34 | { pageUrl: "https://example.com/docs", faviconUrl: "https://example.com/icon.png" }, |
| 35 | "light", |
| 36 | ), |
| 37 | ).toBe("https://example.com/icon.png"); |
| 38 | expect( |
| 39 | toolActivityFaviconUrl( |
| 40 | { pageUrl: "https://example.com/docs", faviconUrl: "chrome-extension://example/_favicon/" }, |
| 41 | "light", |
| 42 | ), |
| 43 | ).toBe("https://example.com/favicon.ico"); |
| 44 | }); |
| 45 | }); |