From baaffa1dfdd546ac75cf59183684b42da1663cfa Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 18 May 2020 11:58:32 -0400 Subject: [PATCH] API: gracefully handle cursor w/count <= 0 It just sets these to the default of 25 instead. --- api/graph/model/cursor.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api/graph/model/cursor.go b/api/graph/model/cursor.go index 7039125..e36d0ff 100644 --- a/api/graph/model/cursor.go +++ b/api/graph/model/cursor.go @@ -51,9 +51,13 @@ func derefOrInt(i *int, d int) int { func NewCursor(filter *Filter) *Cursor { if filter != nil { + count := derefOrInt(filter.Count, 25) + if count <= 0 { + count = 25 + } return &Cursor{ Next: "", - Count: derefOrInt(filter.Count, 25), + Count: count, Search: "", // TODO } } -- 2.38.4