Skip to content

Commit 6d41ad8

Browse files
author
Phil Varner
authored
fix bug where next param was missing when sortby was specified (#686)
1 parent 2bb014a commit 6d41ad8

File tree

4 files changed

+29
-20
lines changed

4 files changed

+29
-20
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## [3.5.0] - 2024-01-19
9+
10+
### Fixed
11+
12+
- When using sortby, next links were incorrect.
13+
814
## [3.4.0] - 2023-12-15
915

1016
### Changed
@@ -422,6 +428,7 @@ Initial release, forked from [sat-api](https://github.com/sat-utils/sat-api/tree
422428
Compliant with STAC 0.9.0
423429

424430
<!-- [Unreleased]: https://github.com/stac-utils/stac-api/compare/v3.3.0...main -->
431+
[3.5.0]: https://github.com/stac-utils/stac-api/compare/v3.4.0...v3.5.0
425432
[3.4.0]: https://github.com/stac-utils/stac-api/compare/v3.3.0...v3.4.0
426433
[3.3.0]: https://github.com/stac-utils/stac-api/compare/v3.2.0...v3.3.0
427434
[3.2.0]: https://github.com/stac-utils/stac-api/compare/v3.1.0...v3.2.0

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"displayName": "stac-server",
33
"description": "A STAC API running on stac-server",
4-
"version": "3.4.0",
4+
"version": "3.5.0",
55
"repository": "https://github.com/stac-utils/stac-server",
66
"author": "Alireza Jazayeri, Matthew Hanson, Sean Harkins, Phil Varner",
77
"license": "MIT",

src/lib/api.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -549,27 +549,29 @@ const buildPaginationLinks = function (limit, parameters, bbox, intersects, endp
549549

550550
const lastItem = items[items.length - 1]
551551

552-
const nextKeys = sortby ? Object.keys(sortby) : ['properties.datetime', 'id', 'collection']
552+
const nextKeys = sortby ? sortby.map((x) => x.field)
553+
: ['properties.datetime', 'id', 'collection']
553554

554555
const next = nextKeys.map((k) => getNested(lastItem, k)).join(',')
555556

556-
const nextParams = pickBy(assign(parameters, { bbox, intersects, limit, next }))
557-
558-
const link = {
559-
rel: 'next',
560-
title: 'Next page of Items',
561-
method: httpMethod,
562-
type: 'application/geo+json'
563-
}
564-
if (httpMethod === 'GET') {
565-
const nextQueryParameters = dictToURI(nextParams)
566-
link.href = `${endpoint}?${nextQueryParameters}`
567-
} else if (httpMethod === 'POST') {
568-
link.href = endpoint
569-
link.merge = false
570-
link.body = nextParams
557+
if (next) {
558+
const link = {
559+
rel: 'next',
560+
title: 'Next page of Items',
561+
method: httpMethod,
562+
type: 'application/geo+json'
563+
}
564+
const nextParams = pickBy(assign(parameters, { bbox, intersects, limit, next }))
565+
if (httpMethod === 'GET') {
566+
const nextQueryParameters = dictToURI(nextParams)
567+
link.href = `${endpoint}?${nextQueryParameters}`
568+
} else if (httpMethod === 'POST') {
569+
link.href = endpoint
570+
link.merge = false
571+
link.body = nextParams
572+
}
573+
return [link]
571574
}
572-
return [link]
573575
}
574576
return []
575577
}

0 commit comments

Comments
 (0)