-
-
Notifications
You must be signed in to change notification settings - Fork 981
Closed
Labels
Description
Describe the bug
- Node.js version: v12.22.1
- OS & version: MacOS Big Sur, Ubuntu 20
Sometimes (e.g. with Buildkite REST API), a response can contain a link header that is an empty string. The default paginate logic (see just below) doesn't handle this case and will throw when it tries to parse the string. This means we need to add our own paginate logic that is almost identical to the default.
Current default function:
Line 677 in 06a2d3d
| if (typeof response.headers.link !== 'string') { |
A fix:
if (typeof response.headers.link !== 'string' || response.headers.link === '') {
return false;
}Actual behavior
got throws when parsing an empty string link header.
Expected behavior
The default pagination.paginate function should return false when the link header is an empty string.
Code to reproduce
const res = got.paginate.all('https://somewebsite.com/that-returns-empty-link-header');
// An example endpoint (requires Buildkite authentication):
// "https://api.buildkite.com/v2/organizations/{org.slug}/pipelines/{pipeline.slug}/builds/{build.number}/jobs/{job.id}/artifacts"Checklist
- I have read the documentation.
- I have tried my code with the latest version of Got.
- I have tried my code with the latest version of Node.js.
Reactions are currently unavailable