From 6f4a7e7b66dda491d43b49c50191f37530a17d18 Mon Sep 17 00:00:00 2001 From: Hamcha Date: Tue, 18 Sep 2018 10:31:02 +0200 Subject: [PATCH] Fix pagination --- scryfall.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scryfall.go b/scryfall.go index 7c12cab..91d1a9f 100644 --- a/scryfall.go +++ b/scryfall.go @@ -66,6 +66,10 @@ func scryfallSearch(query string, offset int) (results CardSearchResults, err er defer response.Body.Close() err = json.NewDecoder(response.Body).Decode(&results) - results.Data = results.Data[cardoffset:] + maxoffset := cardoffset + 50 + if maxoffset > len(results.Data) { + maxoffset = len(results.Data) + } + results.Data = results.Data[cardoffset:maxoffset] return }