mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-21 05:10:25 +08:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user