From 7293c4c23adf903b11fa43c007bb68efaff22d12 Mon Sep 17 00:00:00 2001 From: Peter Potrebic Date: Fri, 31 Mar 2023 04:46:21 -0700 Subject: [PATCH] fix: An emoty string `nextMarker` should be treated as end-of-paging. The Box V2 API docs are inconsistent on this. However it is stated on the paging docs(1): > If this value is null or an empty string there are no more results to fetch. So with this change empty string next_markers will end paging. (1): https://developer.box.com/guides/api-calls/pagination/marker-based/#collections --- Sources/Network/PagingIterator.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/Network/PagingIterator.swift b/Sources/Network/PagingIterator.swift index 3d3a663c1..4b72204a3 100644 --- a/Sources/Network/PagingIterator.swift +++ b/Sources/Network/PagingIterator.swift @@ -94,7 +94,9 @@ public class PagingIterator { nextPage = .streamPosition(nextStreamPosition) } // Handle marker based paging - else if let nextPageMarker = page.nextMarker { + // An Empty string, like a nil `nextMarker`, indicates the end has been reached. + // ref: https://developer.box.com/guides/api-calls/pagination/marker-based/ + else if let nextPageMarker = page.nextMarker, !nextPageMarker.isEmpty { nextPage = .marker(nextPageMarker) } // Handle unexpected value with no paging information