~edwargix/git.sr.ht

baaffa1dfdd546ac75cf59183684b42da1663cfa — Drew DeVault 5 years ago beb2f86
API: gracefully handle cursor w/count <= 0

It just sets these to the default of 25 instead.
1 files changed, 5 insertions(+), 1 deletions(-)

M api/graph/model/cursor.go
M api/graph/model/cursor.go => api/graph/model/cursor.go +5 -1
@@ 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
		}
	}