Skip to content

Commit 9e0ba44

Browse files
committed
fix: remote's visit url must remove the account info part (#2235)
Signed-off-by: leo <longshuang@msn.cn>
1 parent b81c67c commit 9e0ba44

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Models/Remote.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ public bool TryGetVisitURL(out string url)
6666

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

0 commit comments

Comments
 (0)