Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 3e377a9

Browse files
Merge pull request #2228 from github/fixes/2227-exclude-host-name-from-filter
Don't match host name when filtering repositories
2 parents 27e599f + 93f3314 commit 3e377a9

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/GitHub.App/ViewModels/Dialog/Clone/RepositorySelectViewModel.cs

+15-8
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,21 @@ bool FilterItem(object obj)
178178
{
179179
if (obj is IRepositoryItemViewModel item && !string.IsNullOrWhiteSpace(Filter))
180180
{
181-
var urlString = item.Url.ToString();
182-
var urlStringWithGit = urlString + ".git";
183-
var urlStringWithSlash = urlString + "/";
184-
return
185-
item.Caption.Contains(Filter, StringComparison.CurrentCultureIgnoreCase) ||
186-
urlString.Contains(Filter, StringComparison.OrdinalIgnoreCase) ||
187-
urlStringWithGit.Contains(Filter, StringComparison.OrdinalIgnoreCase) ||
188-
urlStringWithSlash.Contains(Filter, StringComparison.OrdinalIgnoreCase);
181+
if (new UriString(Filter).IsHypertextTransferProtocol)
182+
{
183+
var urlString = item.Url.ToString();
184+
var urlStringWithGit = urlString + ".git";
185+
var urlStringWithSlash = urlString + "/";
186+
return
187+
urlString.Contains(Filter, StringComparison.OrdinalIgnoreCase) ||
188+
urlStringWithGit.Contains(Filter, StringComparison.OrdinalIgnoreCase) ||
189+
urlStringWithSlash.Contains(Filter, StringComparison.OrdinalIgnoreCase);
190+
}
191+
else
192+
{
193+
return
194+
item.Caption.Contains(Filter, StringComparison.CurrentCultureIgnoreCase);
195+
}
189196
}
190197

191198
return true;

test/GitHub.App.UnitTests/ViewModels/Dialog/Clone/RepositorySelectViewModelTests.cs

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class TheFilterProperty
2626
[TestCase("https://github.com/jcansdale/TestDriven.Net", "owner", "name", "https://github.com/jcansdale/TestDriven.Net-issues", 1)]
2727
[TestCase("https://github.com/owner/name/", "owner", "name", "https://github.com/owner/name", 1, Description = "Trailing slash")]
2828
[TestCase("https://github.com/owner/name.git", "owner", "name", "https://github.com/owner/name", 1, Description = "Trailing .git")]
29+
[TestCase("github.com", "owner", "name", "https://github.com/owner/name", 0, Description = "Don't include host name in search")]
2930
public async Task Filter(string filter, string owner, string name, string url, int expectCount)
3031
{
3132
var contributedToRepositories = new[]

0 commit comments

Comments
 (0)