Skip to content

Commit e223b80

Browse files
authored
Merge pull request #5066 from sincereliu/master
Optimize code for better performance
2 parents 60068d8 + 5fe468f commit e223b80

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

v2rayN/v2rayN/Handler/ShareHandler.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -266,19 +266,10 @@ private static string GetIpv6(string address)
266266
{
267267
if (Utils.IsIpv6(address))
268268
{
269-
if (address.StartsWith('[') && address.EndsWith(']'))
270-
{
271-
return address;
272-
}
273-
else
274-
{
275-
return $"[{address}]";
276-
}
277-
}
278-
else
279-
{
280-
return address;
269+
// 检查地址是否已经被方括号包围,如果没有,则添加方括号
270+
return address.StartsWith('[') && address.EndsWith(']') ? address : $"[{address}]";
281271
}
272+
return address; // 如果不是IPv6地址,直接返回原地址
282273
}
283274

284275
private static int GetStdTransport(ProfileItem item, string? securityDef, ref Dictionary<string, string> dicQuery)

0 commit comments

Comments
 (0)