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

Commit fde9cb1

Browse files
committed
Match repos with a trailing / or .git
1 parent b33ed8b commit fde9cb1

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,14 @@ bool FilterItem(object obj)
179179
{
180180
if (obj is IRepositoryItemViewModel item && !string.IsNullOrWhiteSpace(Filter))
181181
{
182+
var urlString = item.Url.ToString();
183+
var urlStringWithGit = urlString + ".git";
184+
var urlStringWithSlash = urlString + "/";
182185
return
183186
item.Caption.Contains(Filter, StringComparison.CurrentCultureIgnoreCase) ||
184-
item.Url.ToString().Contains(Filter, StringComparison.OrdinalIgnoreCase);
187+
urlString.Contains(Filter, StringComparison.OrdinalIgnoreCase) ||
188+
urlStringWithGit.Contains(Filter, StringComparison.OrdinalIgnoreCase) ||
189+
urlStringWithSlash.Contains(Filter, StringComparison.OrdinalIgnoreCase);
185190
}
186191

187192
return true;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public class TheFilterProperty
2424
[TestCase("HTTPS://GITHUB.COM/OWNER/NAME", "owner", "name", "https://github.com/owner/name", 1)]
2525
[TestCase("https://github.com/owner", "owner", "name", "https://github.com/owner/name", 1)]
2626
[TestCase("https://github.com/jcansdale/TestDriven.Net", "owner", "name", "https://github.com/jcansdale/TestDriven.Net-issues", 1)]
27+
[TestCase("https://github.com/owner/name/", "owner", "name", "https://github.com/owner/name", 1, Description = "Trailing slash")]
28+
[TestCase("https://github.com/owner/name.git", "owner", "name", "https://github.com/owner/name", 1, Description = "Trailing .git")]
2729
public async Task Filter(string filter, string owner, string name, string url, int expectCount)
2830
{
2931
var contributedToRepositories = new[]

0 commit comments

Comments
 (0)