Skip to content

Commit 73cc5a9

Browse files
VictoriousRaptorcubic-dev-ai[bot]Copilot
authored
Fix ipv6 any address and numeric TLD
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 4942eab commit 73cc5a9

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

  • Plugins/Flow.Launcher.Plugin.Url

Plugins/Flow.Launcher.Plugin.Url/Main.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ public bool IsURL(string raw)
8383
if (decimal.TryParse(input, out _))
8484
return false;
8585

86-
// Check if it's a bare IP address with optional port and path
87-
var ipPart = input.Split('/')[0]; // Remove path
88-
if (IPEndPoint.TryParse(ipPart, out var endpoint) && !endpoint.Address.Equals(IPAddress.Any))
86+
// Check if it's a bare IP address with optional port, path, query, or fragment
87+
var ipPart = input.Split('/', '?', '#')[0]; // Remove path, query, and fragment
88+
if (IPEndPoint.TryParse(ipPart, out var endpoint) && !endpoint.Address.Equals(IPAddress.Any) && !endpoint.Address.Equals(IPAddress.IPv6Any))
8989
return true;
9090

9191
// Add protocol if missing for Uri validation
@@ -108,16 +108,16 @@ public bool IsURL(string raw)
108108

109109
// Valid IP address (excluding 0.0.0.0)
110110
if (IPAddress.TryParse(host, out var hostIp))
111-
return !hostIp.Equals(IPAddress.Any);
111+
return !hostIp.Equals(IPAddress.Any) && !hostIp.Equals(IPAddress.IPv6Any);
112112

113113
// Domain must have valid format with TLD
114114
var parts = host.Split('.');
115115
if (parts.Length < 2 || parts.Any(string.IsNullOrEmpty))
116116
return false;
117117

118-
// TLD must be at least 2 letters
118+
// TLD must be at least 2 characters, allowing letters and digits
119119
var tld = parts[^1];
120-
return tld.Length >= 2 && tld.All(char.IsLetter);
120+
return tld.Length >= 2 && tld.All(char.IsLetterOrDigit);
121121
}
122122

123123
public void Init(PluginInitContext context)

0 commit comments

Comments
 (0)