You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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
constres=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.
The text was updated successfully, but these errors were encountered:
Note that I have separately raised the issue of returning an empty link header with Buildkite as well, but I figured we could also improve the default paginate function here 🙂
Good question. This doc is the closest spec I found, which outlines what a link string should look like, but doesn't explicitly say anything about an empty link. Might be up to you how to handle this case 😄
Describe the bug
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:
got/source/core/options.ts
Line 677 in 06a2d3d
A fix:
Actual behavior
got
throws when parsing an empty string link header.Expected behavior
The default
pagination.paginate
function should returnfalse
when the link header is an empty string.Code to reproduce
Checklist
The text was updated successfully, but these errors were encountered: