diff --git a/github/github.go b/github/github.go index a7afd83436..ee3bb0ab73 100644 --- a/github/github.go +++ b/github/github.go @@ -544,7 +544,7 @@ func (r *Response) populatePageValues() { continue } - if since != "" { + if since != "" && page == "" { page = since } diff --git a/github/github_test.go b/github/github_test.go index 3a0c293127..06059e6dc4 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -677,6 +677,35 @@ func TestResponse_populateSinceValues(t *testing.T) { } } +func TestResponse_SinceWithPage(t *testing.T) { + r := http.Response{ + Header: http.Header{ + "Link": {`; rel="first",` + + ` ; rel="prev",` + + ` ; rel="next",` + + ` ; rel="last"`, + }, + }, + } + + response := newResponse(&r) + if got, want := response.FirstPage, 1; got != want { + t.Errorf("response.FirstPage: %v, want %v", got, want) + } + if got, want := response.PrevPage, 2; want != got { + t.Errorf("response.PrevPage: %v, want %v", got, want) + } + if got, want := response.NextPage, 4; want != got { + t.Errorf("response.NextPage: %v, want %v", got, want) + } + if got, want := response.LastPage, 5; want != got { + t.Errorf("response.LastPage: %v, want %v", got, want) + } + if got, want := response.NextPageToken, ""; want != got { + t.Errorf("response.NextPageToken: %v, want %v", got, want) + } +} + func TestResponse_cursorPagination(t *testing.T) { r := http.Response{ Header: http.Header{