Skip to content

Commit 2b77ae4

Browse files
philvarnerPhil Varner
andauthored
fix next link when using _filter (#1005)
Co-authored-by: Phil Varner <[email protected]>
1 parent d6dddde commit 2b77ae4

File tree

3 files changed

+104
-80
lines changed

3 files changed

+104
-80
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2121
are replaced with proxy endpoint URLs and the original S3 URLs are preserved in
2222
`alternate.s3.href` using the Alternate Assets Extension.
2323

24+
### Fixed
25+
26+
- When using the `_filter` parameter, the combined filter was returned in the `next` link
27+
body. This had the correct semantics, but the size of the filter would grow by one
28+
`and` nesting each pagination request, as the `_filter` was repeatedly added to body.
29+
2430
## [4.4.0] - 2025-09-10
2531

2632
## Changed

package-lock.json

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

src/lib/api.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,10 @@ const wrapResponseInFeatureCollection = function (features, links,
576576
return fc
577577
}
578578

579-
const buildPaginationLinks = function (limit, parameters, bbox, intersects, collections, endpoint,
580-
httpMethod, sortby, items) {
579+
const buildPaginationLinks = function (
580+
limit, parameters, bbox, intersects, collections, filter,
581+
endpoint, httpMethod, sortby, items
582+
) {
581583
if (items.length) {
582584
const dictToURI = (dict) => (
583585
Object.keys(dict).map(
@@ -620,7 +622,9 @@ const buildPaginationLinks = function (limit, parameters, bbox, intersects, coll
620622
method: httpMethod,
621623
type: 'application/geo+json'
622624
}
623-
const nextParams = pickBy(assign(parameters, { bbox, intersects, limit, next, collections }))
625+
const nextParams = pickBy(
626+
assign(parameters, { bbox, intersects, limit, next, collections, filter })
627+
)
624628
if (httpMethod === 'GET') {
625629
const nextQueryParameters = dictToURI(nextParams)
626630
link.href = `${endpoint}?${nextQueryParameters}`
@@ -655,8 +659,10 @@ const searchItems = async function (
655659

656660
const sortby = extractSortby(parameters)
657661
const query = extractStacQuery(parameters)
658-
const filter = concatenateCql2Filters(
659-
extractCql2Filter(parameters),
662+
const specifiedFilter = extractCql2Filter(parameters)
663+
664+
const combinedFilter = concatenateCql2Filters(
665+
specifiedFilter,
660666
extractRestrictionCql2Filter(parameters, headers)
661667
)
662668
const fields = extractFields(parameters)
@@ -674,7 +680,7 @@ const searchItems = async function (
674680
datetime,
675681
intersects: geometry,
676682
query,
677-
filter: filter,
683+
filter: combinedFilter,
678684
sortby,
679685
fields,
680686
ids,
@@ -730,6 +736,7 @@ const searchItems = async function (
730736
bbox,
731737
intersects,
732738
specifiedCollectionIds,
739+
specifiedFilter,
733740
newEndpoint,
734741
httpMethod,
735742
sortby,

0 commit comments

Comments
 (0)