From c565f22bf253130f79d2b396633fa9af21d97212 Mon Sep 17 00:00:00 2001 From: Maurice Date: Sun, 31 May 2026 21:54:16 +0200 Subject: [PATCH] Fix Taiwan resolving to CN-TW in the Atlas country search (#1049) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit natural-earth gives Taiwan ISO_A2='CN-TW' (a subdivision-style value) with ADM0_A3='TWN'. The dynamic A2_TO_A3 augmentation added 'CN-TW'->'TWN', which then overwrote the legitimate TWN->TW entry in the reverse map, so Taiwan's country option resolved to 'CN-TW' — unresolvable by Intl.DisplayNames (no name, broken flag, not searchable). Only augment A2_TO_A3 with real 2-letter codes. --- client/src/pages/atlas/useAtlas.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/src/pages/atlas/useAtlas.ts b/client/src/pages/atlas/useAtlas.ts index 6e5f2422..d8dee913 100644 --- a/client/src/pages/atlas/useAtlas.ts +++ b/client/src/pages/atlas/useAtlas.ts @@ -141,7 +141,10 @@ export function useAtlas() { for (const f of geo.features) { const a2 = f.properties?.ISO_A2 const a3 = f.properties?.ADM0_A3 || f.properties?.ISO_A3 - if (a2 && a3 && a2 !== '-99' && a3 !== '-99' && !A2_TO_A3[a2]) { + // Only real 2-letter ISO codes: natural-earth uses subdivision-style + // values like "CN-TW" for Taiwan, which would otherwise overwrite the + // legitimate TWN->TW reverse mapping and break the country (#1049). + if (a2 && a3 && a2.length === 2 && a2 !== '-99' && a3 !== '-99' && !A2_TO_A3[a2]) { A2_TO_A3[a2] = a3 } }