X Tutup
Skip to content

Commit 0e51ec1

Browse files
committed
Correct benign mistake in off-by-one guard
m[2] is the third element of m, rather than the second, so we have to check instead that the len of m is at least 3. Because the regular expression has two capture groups, the length of m will always be 3, so currently the guard will always be true.
1 parent 8a56359 commit 0e51ec1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

pkg/cmd/api/pagination.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var linkRE = regexp.MustCompile(`<([^>]+)>;\s*rel="([^"]+)"`)
1414

1515
func findNextPage(resp *http.Response) (string, bool) {
1616
for _, m := range linkRE.FindAllStringSubmatch(resp.Header.Get("Link"), -1) {
17-
if len(m) >= 2 && m[2] == "next" {
17+
if len(m) > 2 && m[2] == "next" {
1818
return m[1], true
1919
}
2020
}

pkg/cmd/secret/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ var linkRE = regexp.MustCompile(`<([^>]+)>;\s*rel="([^"]+)"`)
250250

251251
func findNextPage(link string) string {
252252
for _, m := range linkRE.FindAllStringSubmatch(link, -1) {
253-
if len(m) >= 2 && m[2] == "next" {
253+
if len(m) > 2 && m[2] == "next" {
254254
return m[1]
255255
}
256256
}

0 commit comments

Comments
 (0)
X Tutup