fknop / hapi-pagination

Hapi plugin to handle "custom" pagination
MIT License
63 stars 36 forks source link

`last` link incorrectly populated when result is empty #88

Open richardlay opened 4 years ago

richardlay commented 4 years ago

When upgrading from 3.0.0 to 4.0.0, my test for when the result is empty broke.

In 3.0.0 the meta.last field was not populated. This is what meta looks like:

{
  count: 0,
  pageCount: 0,
  totalCount: 0,
  next: null,
  previous: null,
  self: 'http://localhost:3000/testPagination?page=1&limit=25',
  first: 'http://localhost:3000/testPagination?page=1&limit=25',
  last: null
}

In 4.0.0 the meta.last field has a 0 indexed link. This is what meta looks like:

{
  count: 0,
  pageCount: 0,
  totalCount: 0,
  next: null,
  previous: null,
  self: 'http://localhost:3000/testPagination?page=1&limit=25',
  first: 'http://localhost:3000/testPagination?page=1&limit=25',
  last: 'http://localhost:3000/testPagination?page=0&limit=25'
}