util.go 899 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
  5. */
  6. package main
  7. import "strings"
  8. func getLinkNext(link string) (next string) {
  9. // this could be made faster, but doesn't seem necessary
  10. // See https://www.w3.org/wiki/LinkHeader for details.
  11. // basic format: `<meta.rdf>; rel=meta, ...`
  12. before, _, found := strings.Cut(link, `rel="next"`)
  13. if !found {
  14. return
  15. }
  16. idx := strings.LastIndex(before, "<")
  17. if idx == -1 {
  18. return
  19. }
  20. r := strings.NewReader(before)
  21. _, err := r.ReadAt([]byte(next), int64(idx+1))
  22. if err != nil {
  23. return
  24. }
  25. parts := strings.Split(next, ">")
  26. if len(parts) != 2 {
  27. return
  28. }
  29. next = parts[0]
  30. return
  31. }
  32. type GitRepo interface {
  33. Path() string
  34. GitURI() string
  35. WebURI() string
  36. DefaultBranch() string
  37. }