From db55b1746a69ae811042d9d8771959134b0cc184 Mon Sep 17 00:00:00 2001 From: InfiniteTF Date: Wed, 12 Jan 2022 01:34:11 +0100 Subject: [PATCH] Show country flags for ISO coded countries (#2230) --- ui/v2.5/src/utils/country.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/v2.5/src/utils/country.ts b/ui/v2.5/src/utils/country.ts index 20555abb8..d9961a388 100644 --- a/ui/v2.5/src/utils/country.ts +++ b/ui/v2.5/src/utils/country.ts @@ -20,8 +20,10 @@ const fuzzyDict: Record = { const getISOCountry = (country: string | null | undefined) => { if (!country) return null; - const code = fuzzyDict[country] ?? Countries.getAlpha2Code(country, "en"); - if (!code) return null; + const code = + fuzzyDict[country] ?? Countries.getAlpha2Code(country, "en") ?? country; + // Check if code is valid alpha2 iso + if (!Countries.alpha2ToAlpha3(code)) return null; return { code,