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

Function nextPage

pkg/search/searcher.go:346–363  ·  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

344//
345// [docs]: https://docs.github.com/en/rest/using-the-rest-api/using-pagination-in-the-rest-api
346func nextPage(link string) (page int) {
347 // When using pagination, responses get a "Link" field in their header.
348 // When a next page is available, "Link" contains a link to the next page
349 // tagged with rel="next".
350 for _, m := range linkRE.FindAllStringSubmatch(link, -1) {
351 if !(len(m) > 2 && m[2] == "next") {
352 continue
353 }
354 p := pageRE.FindStringSubmatch(m[1])
355 if len(p) == 3 {
356 i, err := strconv.Atoi(p[2])
357 if err == nil {
358 return i
359 }
360 }
361 }
362 return 0
363}
364
365func min(a, b int) int {
366 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