diff --git a/src/server/internalServer.cpp b/src/server/internalServer.cpp index 5c5ecbf30..96fcd5f2a 100644 --- a/src/server/internalServer.cpp +++ b/src/server/internalServer.cpp @@ -720,7 +720,8 @@ InternalServer::search_catalog(const RequestContext& request, const auto totalResults = bookIdsToDump.size(); const size_t count = request.get_optional_param("count", 10UL); const size_t startIndex = request.get_optional_param("start", 0UL); - bookIdsToDump = subrange(bookIdsToDump, startIndex, count); + const size_t intendedCount = count > 0 ? count : bookIdsToDump.size(); + bookIdsToDump = subrange(bookIdsToDump, startIndex, intendedCount); opdsDumper.setOpenSearchInfo(totalResults, startIndex, bookIdsToDump.size()); return bookIdsToDump; } diff --git a/test/server.cpp b/test/server.cpp index 9acf8e595..334f6079b 100644 --- a/test/server.cpp +++ b/test/server.cpp @@ -939,8 +939,11 @@ TEST_F(LibraryServerTest, catalog_search_results_pagination) " YYYY-MM-DDThh:mm:ssZ\n" " 3\n" " 0\n" - " 0\n" + " 3\n" CATALOG_LINK_TAGS + CHARLES_RAY_CATALOG_ENTRY + RAY_CHARLES_CATALOG_ENTRY + UNCATEGORIZED_RAY_CHARLES_CATALOG_ENTRY "\n" ); }