ThatAIguyA world of ideas

THE CONSCIOUSNESS ATLAS
Read. Experiment. Follow the evidence.

ConsciousnessLearn · Explore · Joseph Anady

Janady13/llms-txt-hub / apps/web/components/forms/submit-form-utils.ts

Source identity, revision, and recovered contents.

GitHub sourceSource text recovered

Source identity

FieldRecorded value
Source typeGitHub source
Original recordJanady13/llms-txt-hub / apps/web/components/forms/submit-form-utils.ts
DateNot specified in source
RepositoryJanady13/llms-txt-hub
Revisione0f4bf978d4df168369c7601d9c5f5ea89e84377
Branchmain
Path or archive memberapps/web/components/forms/submit-form-utils.ts
Original SHA-2569ba51b5cf1400572c49d419bd104b2fdec6281a717165249b9276f24bcb69f78
Git blob SHAdf9c3bc3c41250f902b855ea3b495cc712a656d0
Reading-copy SHA-2569ba51b5cf1400572c49d419bd104b2fdec6281a717165249b9276f24bcb69f78

Original source ↗

Recovered source transcript

/** * Utility functions for the submit form */ /** * Normalizes a domain by removing protocol, www prefix, and handling edge cases */ export function normalizeDomain(url: string): string { try { // Clean URL by removing whitespace and newline characters const cleanedUrl = url ? url.trim().replace(/[\r\n\t]/g, '') : '' if (!cleanedUrl) return '' const parsedUrl = new URL(cleanedUrl) let hostname = parsedUrl.hostname.toLowerCase() // Remove www prefix hostname = hostname.replace(/^www\./, '') // Handle localhost and development environments if ( hostname === 'localhost' || hostname.match(/^127\.0\.0\.1$/) || hostname.match(/^192\.168\./) ) { return hostname + (parsedUrl.port ? `:${parsedUrl.port}` : '') } return hostname } catch { return '' } } /** * Checks if two URLs belong to the same domain */ export function isSameDomain(url1: string, url2: string): boolean { const domain1 = normalizeDomain(url1) const domain2 = normalizeDomain(url2) return domain1 === domain2 && domain1 !== '' } /** * Generates a llms.txt URL from a website URL */ export function generateLlmsUrl(websiteUrl: string): string { if (!websiteUrl) return '' try { const cleanedUrl = websiteUrl.trim().replace(/[\r\n\t]/g, '') const url = new URL(cleanedUrl) return `${url.origin}/llms.txt` } catch { return '' } } /** * Generates a llms-full.txt URL from a website URL */ export function generateLlmsFullUrl(websiteUrl: string): string { if (!websiteUrl) return '' try { const cleanedUrl = websiteUrl.trim().replace(/[\r\n\t]/g, '') const url = new URL(cleanedUrl) return `${url.origin}/llms-full.txt` } catch { return '' } } /** * Checks if a URL is accessible */ export async function checkUrl( url: string, setStatus: (status: { checking: boolean; accessible: boolean | null; error?: string }) => void ) { if (!url) { setStatus({ checking: false, accessible: null }) return false } setStatus({ checking: true, accessible: null }) try { const response = await fetch('/api/check-url', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ url }) }) const result = await response.json() setStatus({ checking: false, accessible: result.accessible, error: result.error }) } catch (_error) { setStatus({ checking: false, accessible: false, error: 'Failed to check URL' }) } }

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