修复日志页面卡顿我呢提
This commit is contained in:
Regular → Executable
+21
-4
@@ -12,21 +12,38 @@ class CountryAllowlist
|
||||
*/
|
||||
public static function parse($config)
|
||||
{
|
||||
$config = strtoupper(trim((string) $config));
|
||||
$config = trim((string) $config);
|
||||
if ($config === '') {
|
||||
return [];
|
||||
}
|
||||
$parts = preg_split('/\s*,\s*/', $config);
|
||||
// 支持英文逗号、中文逗号、分号分隔
|
||||
$parts = preg_split('/\s*[,,;]\s*/u', $config);
|
||||
$out = [];
|
||||
foreach ($parts as $part) {
|
||||
$part = trim($part);
|
||||
if ($part !== '') {
|
||||
$out[] = $part;
|
||||
if ($part === '') {
|
||||
continue;
|
||||
}
|
||||
$normalized = CountryCodeNormalizer::toAlpha2($part);
|
||||
if ($normalized !== null && $normalized !== '') {
|
||||
$out[] = $normalized;
|
||||
}
|
||||
}
|
||||
return array_values(array_unique($out));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存配置前规范化国家列表字符串(dashboard 写入用)
|
||||
*
|
||||
* @param string $config
|
||||
* @return string 如 BR,CN
|
||||
*/
|
||||
public static function formatForConfig($config)
|
||||
{
|
||||
$list = self::parse($config);
|
||||
return implode(',', $list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $countryCode
|
||||
* @param string[] $allowlist
|
||||
|
||||
Reference in New Issue
Block a user