From 117ddd17d742a486d7269116b0d1ee8d2ff639b4 Mon Sep 17 00:00:00 2001 From: Viktor Lofgren Date: Sat, 16 Dec 2023 17:07:17 +0100 Subject: [PATCH] (assistant) Fix bugs in IP flag emoji generation --- .../assistant/client/model/DomainInformation.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/code/api/assistant-api/src/main/java/nu/marginalia/assistant/client/model/DomainInformation.java b/code/api/assistant-api/src/main/java/nu/marginalia/assistant/client/model/DomainInformation.java index 5cf28278..9e0489ee 100644 --- a/code/api/assistant-api/src/main/java/nu/marginalia/assistant/client/model/DomainInformation.java +++ b/code/api/assistant-api/src/main/java/nu/marginalia/assistant/client/model/DomainInformation.java @@ -26,13 +26,15 @@ public class DomainInformation { String state; public String getIpFlag() { - if (ipCountry == null || ipCountry.isBlank()) { + if (ipCountry == null || ipCountry.codePointCount(0, ipCountry.length()) != 2) { return ""; } String country = ipCountry; + if ("UK".equals(country)) { - return "GB"; + country = "GB"; } + int offset = 0x1F1E6; int asciiOffset = 0x41; int firstChar = Character.codePointAt(country, 0) - asciiOffset + offset;