/catalog/search?count=0 returns all entries

This commit is contained in:
Veloman Yunkan 2022-01-21 19:31:46 +04:00
parent 08c3a9d8b2
commit b8328a78f6
2 changed files with 6 additions and 2 deletions

View File

@ -720,7 +720,8 @@ InternalServer::search_catalog(const RequestContext& request,
const auto totalResults = bookIdsToDump.size(); const auto totalResults = bookIdsToDump.size();
const size_t count = request.get_optional_param("count", 10UL); const size_t count = request.get_optional_param("count", 10UL);
const size_t startIndex = request.get_optional_param("start", 0UL); 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()); opdsDumper.setOpenSearchInfo(totalResults, startIndex, bookIdsToDump.size());
return bookIdsToDump; return bookIdsToDump;
} }

View File

@ -939,8 +939,11 @@ TEST_F(LibraryServerTest, catalog_search_results_pagination)
" <updated>YYYY-MM-DDThh:mm:ssZ</updated>\n" " <updated>YYYY-MM-DDThh:mm:ssZ</updated>\n"
" <totalResults>3</totalResults>\n" " <totalResults>3</totalResults>\n"
" <startIndex>0</startIndex>\n" " <startIndex>0</startIndex>\n"
" <itemsPerPage>0</itemsPerPage>\n" " <itemsPerPage>3</itemsPerPage>\n"
CATALOG_LINK_TAGS CATALOG_LINK_TAGS
CHARLES_RAY_CATALOG_ENTRY
RAY_CHARLES_CATALOG_ENTRY
UNCATEGORIZED_RAY_CHARLES_CATALOG_ENTRY
"</feed>\n" "</feed>\n"
); );
} }