refactor: do not handle port of remote URL since we can not know if the ssh port changed by a changed https port

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo
2026-03-17 19:24:01 +08:00
parent 6f16791f51
commit 16a66d4dff
2 changed files with 3 additions and 9 deletions

View File

@@ -64,14 +64,9 @@ namespace SourceGit.Models
{
url = null;
if (URL.StartsWith("http", StringComparison.Ordinal))
if (URL.StartsWith("http://", StringComparison.Ordinal) || URL.StartsWith("https://", StringComparison.Ordinal))
{
var uri = new Uri(URL.EndsWith(".git", StringComparison.Ordinal) ? URL.Substring(0, URL.Length - 4) : URL);
if (uri.Port != 80 && uri.Port != 443)
url = $"{uri.Scheme}://{uri.Host}:{uri.Port}{uri.LocalPath}";
else
url = $"{uri.Scheme}://{uri.Host}{uri.LocalPath}";
url = URL.EndsWith(".git", StringComparison.Ordinal) ? URL.Substring(0, URL.Length - 4) : URL;
return true;
}

View File

@@ -45,11 +45,10 @@ namespace SourceGit.Views
if (url.StartsWith("https://", StringComparison.Ordinal) && Uri.TryCreate(url, UriKind.Absolute, out var uri))
{
var host = uri.Host;
var serverName = uri.Port == 443 ? host : $"{host}:{uri.Port}";
var route = uri.AbsolutePath.TrimStart('/');
_protocols.Add(url);
_protocols.Add($"git@{serverName}:{route}");
_protocols.Add($"git@{host}:{route}");
SetCurrentValue(ActiveProtocolProperty, "HTTPS");
SetCurrentValue(IsVisibleProperty, true);