fix: handle out-of-bounds page parameter gracefully (#1103)#1119
Open
tejasdev wants to merge 6 commits intoppetzold:masterfrom
Open
fix: handle out-of-bounds page parameter gracefully (#1103)#1119tejasdev wants to merge 6 commits intoppetzold:masterfrom
tejasdev wants to merge 6 commits intoppetzold:masterfrom
Conversation
- Clamp `currentPage` to valid range (1 to totalPages) - Fix links generation to use clamped `currentPage` - Prevent invalid `next` and `last` links when on last page - Add tests for edge cases (page=0, page > totalPages)
There was a problem hiding this comment.
Pull request overview
This PR fixes out-of-bounds page parameter handling by introducing a clamped currentPage value that constrains page numbers to the valid range [1, totalPages]. However, the implementation has critical issues with inconsistent application of the clamping logic.
Key Changes:
- Introduced
currentPagevariable that clamps the page parameter to [1, totalPages] - Updated metadata to use clamped
currentPageinstead of rawpage - Partially updated link generation to use clamped value (only for
currentlink)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/paginate.ts | Adds clamping logic for currentPage and updates meta/links to use it (lines 982, 989, 1014), plus formatting changes (lines 225-230) |
| src/paginate.spec.ts | Adds test cases for out-of-bounds page parameter handling (lines 3138-3167) and additional link assertions (lines 3640-3641) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
added 5 commits
January 1, 2026 14:32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes out-of-bounds page parameter handling by clamping currentPage to valid range.
Changes
currentPageto range [1, totalPages]currentPageRelated Issue
Closes #1103
Testing