(assistant) Fix bugs in IP flag emoji generation

This commit is contained in:
Viktor Lofgren 2023-12-16 17:07:17 +01:00
parent 6f2bf38f0e
commit 117ddd17d7

View File

@ -26,13 +26,15 @@ public class DomainInformation {
String state; String state;
public String getIpFlag() { public String getIpFlag() {
if (ipCountry == null || ipCountry.isBlank()) { if (ipCountry == null || ipCountry.codePointCount(0, ipCountry.length()) != 2) {
return ""; return "";
} }
String country = ipCountry; String country = ipCountry;
if ("UK".equals(country)) { if ("UK".equals(country)) {
return "GB"; country = "GB";
} }
int offset = 0x1F1E6; int offset = 0x1F1E6;
int asciiOffset = 0x41; int asciiOffset = 0x41;
int firstChar = Character.codePointAt(country, 0) - asciiOffset + offset; int firstChar = Character.codePointAt(country, 0) - asciiOffset + offset;