@devries-cameron20 / t3code Mirror · read-only
Fork 0

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

main
ts 44 lines 1.3 KB
Raw
1 import { WORKSPACE_IMAGE_PREVIEW_EXTENSIONS } from "./mediaPreview.ts";
2
3 export const PROJECT_FAVICON_FALLBACK_MARKER = "project-favicon-missing";
4
5 export const PROJECT_FAVICON_EXTENSIONS = [...WORKSPACE_IMAGE_PREVIEW_EXTENSIONS, ".icns"] as const;
6
7 export function isProjectFaviconPath(path: string): boolean {
8 const literalPath = path.toLowerCase();
9 return PROJECT_FAVICON_EXTENSIONS.some((extension) => literalPath.endsWith(extension));
10 }
11
12 export function getProjectFaviconResourceKey(
13 environmentId: string,
14 workspaceRoot: string,
15 faviconPath?: string | null,
16 ) {
17 return JSON.stringify([environmentId, workspaceRoot, faviconPath || null]);
18 }
19
20 export function getProjectFaviconCacheKey(
21 environmentId: string,
22 workspaceRoot: string,
23 url: string,
24 ) {
25 let revision = url;
26
27 try {
28 const pathname = new URL(url, "https://t3.invalid").pathname;
29 revision = pathname.slice(pathname.lastIndexOf("/") + 1);
30 } catch {}
31
32 return JSON.stringify([environmentId, workspaceRoot, revision]);
33 }
34
35 export function isProjectFaviconFallbackUrl(url: string | null | undefined): boolean {
36 if (!url) return false;
37
38 try {
39 const pathname = new URL(url, "https://t3.invalid").pathname;
40 return pathname.slice(pathname.lastIndexOf("/") + 1) === PROJECT_FAVICON_FALLBACK_MARKER;
41 } catch {
42 return false;
43 }
44 }