fix: keystore
This commit is contained in:
@@ -16,15 +16,22 @@ final class CfIpCountry
|
||||
|
||||
public static function normalize(?string $raw): ?string
|
||||
{
|
||||
$code = strtoupper(trim((string) $raw));
|
||||
$trimmed = trim((string) $raw);
|
||||
if ($trimmed === '') {
|
||||
return null;
|
||||
}
|
||||
$code = strtoupper($trimmed);
|
||||
if ($code === 'T1') {
|
||||
return 'T1';
|
||||
}
|
||||
if (preg_match('/^[A-Z]{2}$/', $code) !== 1) {
|
||||
return null;
|
||||
if (preg_match('/^[A-Z]{2}$/', $code) === 1) {
|
||||
return $code;
|
||||
}
|
||||
|
||||
return $code;
|
||||
// Allow Chinese country names (e.g. "中国" -> "CN") via reverse lookup.
|
||||
$hit = array_search($trimmed, self::names(), true);
|
||||
|
||||
return $hit !== false ? (string) $hit : null;
|
||||
}
|
||||
|
||||
public static function label(?string $code): string
|
||||
|
||||
Reference in New Issue
Block a user