From 04e0b9c907928b2a35fd858a86760731b9769892 Mon Sep 17 00:00:00 2001 From: Vincent Boutour Date: Sat, 23 May 2020 10:52:35 +0200 Subject: [PATCH] fix(github): Infinite loop when fetching tags --- pkg/github/github.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/github/github.go b/pkg/github/github.go index 7b6052eb..afa227bc 100644 --- a/pkg/github/github.go +++ b/pkg/github/github.go @@ -91,7 +91,7 @@ func (a app) parseTags(repository string) (semver.Version, error) { } } - if !isLastPage(resp) { + if !hasNext(resp) { break } @@ -105,6 +105,12 @@ func (a app) parseTags(repository string) (semver.Version, error) { return version, nil } -func isLastPage(resp *http.Response) bool { - return !strings.Contains(resp.Header.Get("Link"), `rel="next"`) +func hasNext(resp *http.Response) bool { + for _, value := range resp.Header.Values("Link") { + if strings.Contains(value, `rel="next"`) { + return true + } + } + + return false }