fix:调整兼容域名解析

This commit is contained in:
liyi 2025-02-12 11:00:57 +08:00
parent e6b90d9651
commit f79e5daa47

View File

@ -894,17 +894,16 @@ class StartChartManage {
/// UDP URL IP /// UDP URL IP
Map<String, dynamic> _parseUdpUrl(String url) { Map<String, dynamic> _parseUdpUrl(String url) {
// 使 IP // IP
final regex = RegExp(r'udp://(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):(\d+)') final regex = RegExp(r'udp://([a-zA-Z0-9.-]+):(\d+)').firstMatch(url);
.firstMatch(url);
if (regex != null) { if (regex != null) {
final ip = regex.group(1); final host = regex.group(1);
final portStr = regex.group(2); final portStr = regex.group(2);
final port = int.tryParse(portStr ?? ''); final port = int.tryParse(portStr ?? '');
if (ip != null && port != null) { if (host != null && port != null) {
return {'host': ip, 'port': port}; return {'host': host, 'port': port};
} }
} }
throw FormatException('无法解析 URL 格式: $url'); throw FormatException('无法解析 URL 格式: $url');