{ let input = item.cardData.href?.trim(); if (!input) return; let username: string | undefined; // Try parsing as URL first try { const parsed = new URL(input); if (/^(www\.)?github\.com$/.test(parsed.hostname)) { const segments = parsed.pathname.split('/').filter(Boolean); if ( segments.length === 1 && /^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,37}[a-zA-Z0-9])?$/.test(segments[0]) ) { username = segments[0]; } } } catch { // Not a URL, try as plain username if (/^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,37}[a-zA-Z0-9])?$/.test(input)) { username = input; } } if (!username) { errorMessage = 'Please enter a valid GitHub username or profile URL'; return; } item.cardData.user = username; item.cardData.href = `https://github.com/${username}`; item.w = 6; item.mobileW = 8; item.h = 3; item.mobileH = 6; oncreate?.(); }} class="flex flex-col gap-2" > Enter a GitHub username or profile URL {#if errorMessage}

{errorMessage}

{/if}