MCPcopy Create free account
hub / github.com/cli/cli / nextPage

Function nextPage

pkg/search/searcher.go:325–342  ·  view source on GitHub ↗

nextPage extracts the next page number from an API response's link header. if the provided link header is empty or there is no next page, zero is returned. See API [docs] on pagination for more information. [docs]: https://docs.github.com/en/rest/using-the-rest-api/using-pagination-in-the-rest-api

(link string)

Source from the content-addressed store, hash-verified

323//
324// [docs]: https://docs.github.com/en/rest/using-the-rest-api/using-pagination-in-the-rest-api
325func nextPage(link string) (page int) {
326 // When using pagination, responses get a "Link" field in their header.
327 // When a next page is available, "Link" contains a link to the next page
328 // tagged with rel="next".
329 for _, m := range linkRE.FindAllStringSubmatch(link, -1) {
330 if !(len(m) > 2 && m[2] == "next") {
331 continue
332 }
333 p := pageRE.FindStringSubmatch(m[1])
334 if len(p) == 3 {
335 i, err := strconv.Atoi(p[2])
336 if err == nil {
337 return i
338 }
339 }
340 }
341 return 0
342}
343
344func min(a, b int) int {
345 if a < b {

Callers 4

CodeMethod · 0.85
CommitsMethod · 0.85
RepositoriesMethod · 0.85
IssuesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected