diff --git a/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs index 2afea59ccf..d2283388b0 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs @@ -222,6 +222,18 @@ public async Task GetsDirectoryContent() 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() { diff --git a/Octokit/Clients/RepositoryContentsClient.cs b/Octokit/Clients/RepositoryContentsClient.cs index 96056f67fd..92ccfd45e4 100644 --- a/Octokit/Clients/RepositoryContentsClient.cs +++ b/Octokit/Clients/RepositoryContentsClient.cs @@ -107,7 +107,9 @@ public Task> GetAllContentsByRef(string owner, 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(url); }