perf: 优化qb下载器端口获取逻辑

This commit is contained in:
Dee Luo
2025-04-11 15:43:40 +08:00
committed by GitHub
parent 86e1f9a9d6
commit 8ca4ea0f3f
+6 -5
View File
@@ -642,13 +642,14 @@ class StringUtils:
if len(parts) > 3: if len(parts) > 3:
# 处理不希望包含多个冒号的情况(除了协议后的冒号) # 处理不希望包含多个冒号的情况(除了协议后的冒号)
return None, None return None, None
elif len(parts) == 3:
port = int(parts[-1])
# 不含端口地址 # 不含端口地址
domain = ":".join(parts[:-1]).rstrip('/') domain = ":".join(parts[:-1]).rstrip('/')
# 端口号 elif len(parts) == 2:
try: port = 443 if address.startswith("https") else 80
port = int(parts[-1]) domain = address
except ValueError: else:
# 端口号不是整数,返回 None 表示无效
return None, None return None, None
return domain, port return domain, port