From 09a76779c9592d22bb8e1955b0a839372bc94a99 Mon Sep 17 00:00:00 2001 From: orangix Date: Wed, 7 Feb 2024 01:13:29 +0000 Subject: [PATCH] check page length before return in nextInTag (#173) fixes #172 Reviewed-on: https://codeberg.org/rimgo/rimgo/pulls/173 Co-authored-by: orangix Co-committed-by: orangix --- pages/post.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pages/post.go b/pages/post.go index 978bd97..8507878 100644 --- a/pages/post.go +++ b/pages/post.go @@ -24,7 +24,8 @@ func nextInTag(client *api.Client, tagname, sort, page, I string) string { if i >= len(tag.Posts)-1 { pageNumber, _ := strconv.Atoi(page) tagn, err := client.FetchTag(tagname, sort, strconv.Itoa(pageNumber+1)) - if err != nil { + // Check length - Imgur will not return an error if there are no more posts and you request the next page + if err != nil || len(tagn.Posts) < 1 { return "" } return tagn.Posts[0].Link