diff --git a/Octokit.Tests.Integration/Clients/SearchClientTests.cs b/Octokit.Tests.Integration/Clients/SearchClientTests.cs index b1267410cc..009965ac5f 100644 --- a/Octokit.Tests.Integration/Clients/SearchClientTests.cs +++ b/Octokit.Tests.Integration/Clients/SearchClientTests.cs @@ -71,6 +71,35 @@ public async Task SearchForFileNameInCodeWithoutTerm() Assert.NotEmpty(repos.Items); } + [IntegrationTest(Skip = "As this repository has been renamed, you cannot search for it's results.")] + public async Task SearchForFileNameInCodeWithoutTerm2() + { + var request = new SearchCodeRequest() + { + FileName = "project.json", + Repos = new RepositoryCollection { "adamcaudill/Psychson" } + }; + + + var repos = await _gitHubClient.Search.SearchCode(request); + + Assert.Empty(repos.Items); + } + + [IntegrationTest] + public async Task SearchForFileNameInCodeWithoutTermWithUnderscore() + { + var request = new SearchCodeRequest() + { + FileName = "readme.md", + Repos = new RepositoryCollection { "Cultural-Rogue/_51Wp.XinFengSDK.Demo" } + }; + + var repos = await _gitHubClient.Search.SearchCode(request); + + Assert.Empty(repos.Items); + } + [IntegrationTest] public async Task SearchForWordInCode() { diff --git a/Octokit/Helpers/StringExtensions.cs b/Octokit/Helpers/StringExtensions.cs index acff888341..50e41f36d2 100644 --- a/Octokit/Helpers/StringExtensions.cs +++ b/Octokit/Helpers/StringExtensions.cs @@ -122,7 +122,7 @@ static IEnumerable SplitUpperCase(this string source) // the rule: // Username may only contain alphanumeric characters or single hyphens // and cannot begin or end with a hyphen - static readonly Regex nameWithOwner = new Regex("[a-z0-9.-]{1,}/[a-z0-9.-]{1,}", + static readonly Regex nameWithOwner = new Regex("[a-z0-9.-]{1,}/[a-z0-9.-_]{1,}", #if (!PORTABLE && !NETFX_CORE) RegexOptions.Compiled | #endif