improve handling of GetAllContentsByRef where root path is requested (#2105)

* add failing test for handling / as the path

* workaround issue by passing in what the API expects
This commit is contained in:
Brendan Forster
2020-02-24 18:12:48 -04:00
committed by GitHub
parent 6fdd800f72
commit 5223d1af5f
2 changed files with 15 additions and 1 deletions
@@ -222,6 +222,18 @@ namespace Octokit.Tests.Integration.Clients
Assert.Equal(ContentType.Dir, contents.First().Type);
}
[IntegrationTest]
public async Task GetsContentNonMasterWithRootPath()
{
var github = Helper.GetAuthenticatedClient();
var contents = await github
.Repository
.Content
.GetAllContentsByRef("octocat", "Spoon-Knife", "/", reference: "test-branch");
Assert.Equal(4, contents.Count);
}
[IntegrationTest]
public async Task GetsDirectoryContentWithRepositoryId()
{
+3 -1
View File
@@ -107,7 +107,9 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(path, nameof(path));
Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference));
var url = ApiUrls.RepositoryContent(owner, name, path, reference);
var url = (path == "/")
? ApiUrls.RepositoryContent(owner, name, "", reference)
: ApiUrls.RepositoryContent(owner, name, path, reference);
return ApiConnection.GetAll<RepositoryContent>(url);
}