Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions app/src/pages/ballot/telex-mandate-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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/<uuid>) and the Telex
// copy-link bug (.../tippjatek//<uuid>)
const match = url.pathname.match(UUID_IN_PATH)
if (match) return match[0]
}
} catch {
// not a valid URL — fall through
Expand Down
Loading