Added to redirect when the page size is invalid in the Pagination utility.
This commit is contained in:
parent
62697fb782
commit
5090e59bb1
@ -117,7 +117,7 @@ class Pagination(t.Generic[T]):
|
||||
page_size: int = int(request.args["page-size"])
|
||||
except ValueError:
|
||||
raise Redirection(self.__uri_set("page-size", None))
|
||||
if page_size == self.DEFAULT_PAGE_SIZE:
|
||||
if page_size == self.DEFAULT_PAGE_SIZE or page_size < 1:
|
||||
raise Redirection(self.__uri_set("page-size", None))
|
||||
return page_size
|
||||
|
||||
|
@ -276,6 +276,9 @@ class PaginationTestCase(unittest.TestCase):
|
||||
f"&page-size={Pagination.DEFAULT_PAGE_SIZE}"
|
||||
"&page-no=37&next=%2F",
|
||||
range(1, 691), "q=word&page-no=37&next=%2F")
|
||||
# An invalid page size
|
||||
self.__test_malformed("q=word&page-size=0&page-no=37&next=%2F",
|
||||
range(1, 691), "q=word&page-no=37&next=%2F")
|
||||
# A malformed page number
|
||||
self.__test_malformed("q=word&page-size=15&page-no=37a&next=%2F",
|
||||
range(1, 691), "q=word&page-size=15&next=%2F")
|
||||
|
Loading…
Reference in New Issue
Block a user