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)
| 344 | // |
| 345 | // [docs]: https://docs.github.com/en/rest/using-the-rest-api/using-pagination-in-the-rest-api |
| 346 | func 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 | |
| 365 | func min(a, b int) int { |
| 366 | if a < b { |
no outgoing calls
no test coverage detected