getCountry()function
getCountry(value: unknown = "detect"): Country | undefined
| Param | Type | |
|---|---|---|
value | unknown | The country code to parse, or "detect" to read it from the browser. Defaults to "detect". Defaults to "detect" |
| Return | |
|---|---|
Country | undefined | The matching Country code, or undefined if it could not be resolved. |
Parse a country string, or detect a browser country from navigator.language.
- When
valueis"detect", reads the last two characters ofnavigator.language(if available). - Matching is case-insensitive; the value is uppercased before lookup.
Examples
getCountry("gb") // "GB"