diff --git a/app/src/pages/ballot/telex-mandate-section.tsx b/app/src/pages/ballot/telex-mandate-section.tsx index 681f334..93f2dcb 100644 --- a/app/src/pages/ballot/telex-mandate-section.tsx +++ b/app/src/pages/ballot/telex-mandate-section.tsx @@ -4,16 +4,22 @@ import { Check, ExternalLink, Link2, X } from 'lucide-react' import type { VotingDraft } from '@/hooks/use-prediction' const TELEX_BASE = 'https://telex.hu/melleklet/valasztas-2026/tippjatek/' +// Full-string test (with anchors) — used to validate a bare UUID input const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i +// Substring search (no anchors) — used to find a UUID anywhere inside a URL path +const UUID_IN_PATH = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i function extractTelexId(input: string): string | null { const trimmed = input.trim() if (UUID_RE.test(trimmed)) return trimmed try { const url = new URL(trimmed) - if (url.hostname === 'telex.hu' && url.pathname.startsWith('/melleklet/valasztas-2026/tippjatek/')) { - const id = url.pathname.replace('/melleklet/valasztas-2026/tippjatek/', '').replace(/\/$/, '') - if (UUID_RE.test(id)) return id + if (url.hostname === 'telex.hu' && url.pathname.includes('/tippjatek/')) { + // UUID_IN_PATH has no anchors so it finds the UUID anywhere in the path, + // handling both the normal form (.../tippjatek/) and the Telex + // copy-link bug (.../tippjatek//) + const match = url.pathname.match(UUID_IN_PATH) + if (match) return match[0] } } catch { // not a valid URL — fall through