Skip to content

Commit b83009c

Browse files
author
Peter Bengtsson
authored
max 10 pages of pagination on dedicated search page (#33915)
1 parent c5b9e93 commit b83009c

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

components/search/SearchResults.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ function ResultsPagination({ page, totalPages }: { page: number; totalPages: num
139139
return (
140140
<Box borderRadius={2} p={2}>
141141
<Pagination
142-
pageCount={totalPages}
142+
pageCount={Math.min(totalPages, 10)}
143143
currentPage={page}
144144
hrefBuilder={hrefBuilder}
145145
onPageChange={(event, page) => {

middleware/api/search.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const MAX_SIZE = 50 // How much you return has a strong impact on performance
2525
const DEFAULT_PAGE = 1
2626
const POSSIBLE_SORTS = ['best', 'relevance']
2727
const DEFAULT_SORT = POSSIBLE_SORTS[0]
28+
const MAX_PAGE = 10
2829

2930
// If someone searches for `...&version=3.5` what they actually mean
3031
// is `ghes-3.5`. This is because of legacy formatting with the old search.
@@ -185,7 +186,7 @@ const validationMiddleware = (req, res, next) => {
185186
key: 'page',
186187
default_: DEFAULT_PAGE,
187188
cast: (v) => parseInt(v, 10),
188-
validate: (v) => v >= 1 && v <= 10,
189+
validate: (v) => v >= 1 && v <= MAX_PAGE,
189190
},
190191
{ key: 'sort', default_: DEFAULT_SORT, validate: (v) => POSSIBLE_SORTS.includes(v) },
191192
{

0 commit comments

Comments
 (0)