feat: support more than one digit of pagination metadata in listUsers()
#793
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.
What kind of change does this PR introduce?
Fixes an issue where the pagination metadata returned from
listUsers()
was inaccurate for page values>= 10
.What is the current behavior?
The current behaviour assumes the
page
value contained in the link string (each element of which looks a bit like this:</admin/users?page=7&per_page=10>; rel="last"
) is always a single digit, leading to truncated values fornextPage
andlastPage
being returned if either are 10 or more. For example, ifnextPage
is10
, the current behaviour truncates this to1
. If the client is relying on the value ofnextPage
, this could cause it to paginate up to page 9 correctly but then reset to page 1 rather than move on to page 10.What is the new behavior?
The new behaviour correctly parses multi-digit values for
nextPage
andlastPage
.Additional context
I couldn't get the test suite running but didn't see any tests relating to this so I don't think any tests will break. I patched the proposed changes into the project I have which was being tripped up by this behaviour and they appear to work as expected. Feel free to refactor - wasn't sure if changing the various
split()
calls to a regex was a no-no.Thanks!