Skip to content

Commit 731f2db

Browse files
authored
Merge pull request #699 from Bene81/gitlab-hostname-only
Gitlab hostname only support.
2 parents 73b4293 + d4300af commit 731f2db

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/shared/Core.Tests/UriExtensionsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void UriExtensions_GetQueryParameters()
2727
}
2828

2929
[Theory]
30-
[InlineData("http://com")]
30+
[InlineData("http://hostname", "http://hostname")]
3131
[InlineData("http://example.com",
3232
"http://example.com")]
3333
[InlineData("http://foo.example.com",

src/shared/Core/UriExtensions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ public static IEnumerable<string> GetGitConfigurationScopes(this Uri uri)
102102
}
103103
}
104104

105+
// Check whether the URL only contains hostname.
106+
// This usually means the host is on your local network.
107+
if (!string.IsNullOrWhiteSpace(host) &&
108+
!host.Contains("."))
109+
{
110+
yield return $"{schemeAndDelim}{host}";
111+
// If we have reached this point, there are no more subdomains to unfold, so exit early.
112+
yield break;
113+
}
114+
105115
// Unfold the host by sub-domain, left-to-right
106116
while (!string.IsNullOrWhiteSpace(host))
107117
{

0 commit comments

Comments
 (0)