Skip to content

Commit 16a66d4

Browse files
committed
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>
1 parent 6f16791 commit 16a66d4

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

src/Models/Remote.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,9 @@ public bool TryGetVisitURL(out string url)
6464
{
6565
url = null;
6666

67-
if (URL.StartsWith("http", StringComparison.Ordinal))
67+
if (URL.StartsWith("http://", StringComparison.Ordinal) || URL.StartsWith("https://", StringComparison.Ordinal))
6868
{
69-
var uri = new Uri(URL.EndsWith(".git", StringComparison.Ordinal) ? URL.Substring(0, URL.Length - 4) : URL);
70-
if (uri.Port != 80 && uri.Port != 443)
71-
url = $"{uri.Scheme}://{uri.Host}:{uri.Port}{uri.LocalPath}";
72-
else
73-
url = $"{uri.Scheme}://{uri.Host}{uri.LocalPath}";
74-
69+
url = URL.EndsWith(".git", StringComparison.Ordinal) ? URL.Substring(0, URL.Length - 4) : URL;
7570
return true;
7671
}
7772

src/Views/RemoteProtocolSwitcher.axaml.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
4545
if (url.StartsWith("https://", StringComparison.Ordinal) && Uri.TryCreate(url, UriKind.Absolute, out var uri))
4646
{
4747
var host = uri.Host;
48-
var serverName = uri.Port == 443 ? host : $"{host}:{uri.Port}";
4948
var route = uri.AbsolutePath.TrimStart('/');
5049

5150
_protocols.Add(url);
52-
_protocols.Add($"git@{serverName}:{route}");
51+
_protocols.Add($"git@{host}:{route}");
5352

5453
SetCurrentValue(ActiveProtocolProperty, "HTTPS");
5554
SetCurrentValue(IsVisibleProperty, true);

0 commit comments

Comments
 (0)