MCPcopy Index your code
hub / github.com/cli/cli / nextPage

Function nextPage

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

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