You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
730 B

1 month ago
export function audienceTicketUrl(slug: string, ticketCode: string): string {
const origin = typeof window !== 'undefined' ? window.location.origin : ''
const basePath = (import.meta.env.BASE_URL || '/').replace(/\/$/, '')
const s = encodeURIComponent(slug)
const code = encodeURIComponent(ticketCode)
return `${origin}${basePath}/c/${s}/t/${code}`
}
export function ticketCodeSuffix(ticketCode: string): string {
const t = ticketCode.trim()
if (!t) return ''
return t.slice(-4).toUpperCase()
}
export function extractTicketCode(raw: string): string {
const t = raw.trim()
if (!t) return ''
const match = t.match(/\/t\/([A-Za-z0-9_-]+)/i)
if (match?.[1]) return match[1]
return t.replace(/\s+/g, '')
}