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

projectFavicon.ts

29 lines817 Bytes

1export const PROJECT_FAVICON_FALLBACK_MARKER = "project-favicon-missing";
2​
3export function getProjectFaviconCacheKey(
4 environmentId: string,
5 workspaceRoot: string,
6 url: string,
7) {
8 let revision = url;
9​
10 try {
11 const pathname = new URL(url, "https://t3.invalid").pathname;
12 revision = pathname.slice(pathname.lastIndexOf("/") + 1);
13 } catch {
14 // Keep the full value as a safe fallback for malformed URLs.
15 }
16​
17 return JSON.stringify([environmentId, workspaceRoot, revision]);
19​
20export function isProjectFaviconFallbackUrl(url: string | null | undefined): boolean {
21 if (!url) return false;
22​
23 try {
24 const pathname = new URL(url, "https://t3.invalid").pathname;
25 return pathname.slice(pathname.lastIndexOf("/") + 1) === PROJECT_FAVICON_FALLBACK_MARKER;
26 } catch {
27 return false;
28 }