12 lines
397 B
JavaScript
12 lines
397 B
JavaScript
export function shinyFlagUrl(countryCode, filesCdnUrl = '') {
|
|
const normalized = String(countryCode ?? '').trim().toUpperCase()
|
|
|
|
if (!/^[A-Z]{2}$/.test(normalized)) {
|
|
return null
|
|
}
|
|
|
|
const base = String(filesCdnUrl ?? '').replace(/\/+$/, '')
|
|
const relativePath = `/images/flags/shiny/24/${encodeURIComponent(normalized)}.png`
|
|
|
|
return base ? `${base}${relativePath}` : relativePath
|
|
} |