ThatAIguyA world of ideas

THE CONSCIOUSNESS ATLAS
Read. Experiment. Follow the evidence.

ConsciousnessLearn · Explore · Joseph Anady

Janady13/llms-txt-hub / packages/utils/get-favicon-url.ts

Source identity, revision, and recovered contents.

GitHub sourceSource text recovered

Source identity

FieldRecorded value
Source typeGitHub source
Original recordJanady13/llms-txt-hub / packages/utils/get-favicon-url.ts
DateNot specified in source
RepositoryJanady13/llms-txt-hub
Revisione0f4bf978d4df168369c7601d9c5f5ea89e84377
Branchmain
Path or archive memberpackages/utils/get-favicon-url.ts
Original SHA-256b1b07fb1dc65ab617a6871bbdf7d0650284fa8fe108695365241015197dc19fa
Git blob SHAd05ea24a762060edb54c1e2de527d659b7ae1650
Reading-copy SHA-256b1b07fb1dc65ab617a6871bbdf7d0650284fa8fe108695365241015197dc19fa

Original source ↗

Recovered source transcript

/** * Google s2 favicons API supported sizes (px). Use highest for best quality on retina. */ const GOOGLE_FAVICON_SIZES = [16, 32, 48, 64, 128, 256] as const const MAX_FAVICON_SIZE = 256 /** * Gets the favicon URL for a given website using Google's s2 favicons API. * @param website - The website URL to get the favicon for * @param size - Preferred size in pixels. Clamped to nearest API size; use 256 for highest resolution. * @returns The favicon URL or placeholder if invalid input */ export function getFaviconUrl(website: string, size: number = MAX_FAVICON_SIZE): string { try { if (!website || typeof website !== 'string') { console.warn('Invalid website URL provided to getFaviconUrl:', website) return '/placeholder.svg' } const normalizedUrl = website.startsWith('http') ? website : `https://${website}` const domain = new URL(normalizedUrl).hostname const sz = size >= MAX_FAVICON_SIZE ? MAX_FAVICON_SIZE : GOOGLE_FAVICON_SIZES.reduce( (prev, curr) => (Math.abs(curr - size) < Math.abs(prev - size) ? curr : prev), GOOGLE_FAVICON_SIZES[0] ) return `https://www.google.com/s2/favicons?domain=${encodeURIComponent(domain)}&sz=${sz}` } catch (error) { console.error(`Error getting favicon for ${website}:`, error) return '/placeholder.svg' } }

Search equations, builds, manuscript text, and recovered sources.