Skip to content

Commit d13786f

Browse files
authored
Fix pagination logic to use next link (#418)
* Fix pagination logic to use `next` link Fixes #414 * Fix tests
1 parent 137871b commit d13786f

File tree

5 files changed

+8
-9
lines changed

5 files changed

+8
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
## 9.25.0-wip
1+
## 9.25.0
22

33
* Require Dart 3.5
44
* Require `package:http` `^1.0.0`.
5+
* Fix pagination logic to use `next` link.
56

67
## 9.24.0
78

lib/src/common/util/pagination.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ class PaginationHelper {
2828
params = Map.from(params);
2929
}
3030

31-
var page = params['page'] ?? 1;
32-
params['page'] = page;
33-
3431
while (true) {
3532
http.Response response;
3633
try {
@@ -70,7 +67,8 @@ class PaginationHelper {
7067
break;
7168
}
7269

73-
params['page'] = ++page;
70+
path = next;
71+
params = null;
7472
}
7573
}
7674

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: github
2-
version: 9.25.0-wip
2+
version: 9.25.0
33
description: A high-level GitHub API Client Library that uses Github's v3 API
44
homepage: https://github.com/SpinlockLabs/github.dart
55

test/common/repos_service_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void main() {
1616
test('listCommits', () async {
1717
final repositories = create((request) async {
1818
expect(request.url.path, '/repos/${slug.fullName}/commits');
19-
expect(request.url.query, 'page=1');
19+
expect(request.url.query, isEmpty);
2020

2121
return Response(listCommits, StatusCodes.OK);
2222
});
@@ -29,7 +29,7 @@ void main() {
2929
expect(request.url.path, '/repos/${slug.fullName}/commits');
3030
expect(
3131
request.url.query,
32-
'author=octocat&committer=octodog&sha=abc&path=%2Fpath&since=2022-02-22T00%3A00%3A00.000&until=2023-02-22T00%3A00%3A00.000&page=1',
32+
'author=octocat&committer=octodog&sha=abc&path=%2Fpath&since=2022-02-22T00%3A00%3A00.000&until=2023-02-22T00%3A00%3A00.000',
3333
);
3434
return Response(listCommits, StatusCodes.OK);
3535
});

test/git_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ void main() {
172172
test('code search', () async {
173173
nock(fakeApiUrl)
174174
.get(
175-
'/search/code?q=search%20repo%3ASpinlockLabs%2Fgithub.dart%20in%3Afile&per_page=20&page=1')
175+
'/search/code?q=search%20repo%3ASpinlockLabs%2Fgithub.dart%20in%3Afile&per_page=20')
176176
.reply(200, nocked.searchResults);
177177

178178
final results = (await github.search

0 commit comments

Comments
 (0)