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