(value: string | null | undefined)
| 46 | : null; |
| 47 | |
| 48 | export function getCountryName(value: string | null | undefined): string { |
| 49 | if (!value) return ""; |
| 50 | const trimmed = value.trim(); |
| 51 | if (!trimmed) return ""; |
| 52 | |
| 53 | // Only attempt to resolve values that look like ISO 3166-1 alpha-2 codes. |
| 54 | if (/^[A-Za-z]{2}$/.test(trimmed) && countryDisplayNames) { |
| 55 | try { |
| 56 | const name = countryDisplayNames.of(trimmed.toUpperCase()); |
| 57 | if (name && name.toUpperCase() !== trimmed.toUpperCase()) { |
| 58 | return name; |
| 59 | } |
| 60 | } catch { |
| 61 | // fall through to return original value |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | return trimmed; |
| 66 | } |
nothing calls this directly
no outgoing calls
no test coverage detected