MCPcopy Create free account
hub / github.com/cursor/community-plugins / getCountryName

Function getCountryName

apps/cursor/src/lib/utils.ts:48–66  ·  view source on GitHub ↗
(value: string | null | undefined)

Source from the content-addressed store, hash-verified

46 : null;
47
48export 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected