@@ -177,7 +177,8 @@ describe("addQueryParametersToItemLink", () => {
177177 } ,
178178 ] ) ;
179179 } ) ;
180- // test for issue CMR-11320
180+ // tests for issue CMR-11320
181+ // tests that q is filtered out
181182 it ( "filters out collection-only query parameters from the item link" , async ( ) => {
182183 const mockRequest = {
183184 method : "GET" ,
@@ -203,6 +204,42 @@ describe("addQueryParametersToItemLink", () => {
203204 } ,
204205 ] ) ;
205206 } ) ;
207+ // tests that the query parameters from list remain in link
208+ it ( "preserves all specified ITEM_QUERY_PARAMS" , async ( ) => {
209+ const originalQuery = [
210+ "datetime=2021-01-01T00:00:00.000Z" ,
211+ "bbox=-180,-90,180,90" ,
212+ "intersects=polygon_data" ,
213+ "query=cloud_cover<10" ,
214+ "limit=100" ,
215+ "sortby=-datetime" ,
216+ "fields=id,properties" ,
217+ ] . join ( "&" ) ;
218+
219+ const mockRequest = {
220+ method : "GET" ,
221+ originalUrl : `/stac/TEST_PROV/collections?${ originalQuery } ` ,
222+ } as Request ;
223+
224+ let stacCollection = generateSTACCollections ( 1 ) [ 0 ] ;
225+ stacCollection . links . push ( {
226+ rel : "items" ,
227+ href : "https://example.com/items" ,
228+ type : "application/geo+json" ,
229+ title : "Collection Items" ,
230+ } ) ;
231+
232+ addQueryParametersToItemLink ( stacCollection , mockRequest ) ;
233+
234+ expect ( stacCollection ) . to . have . deep . property ( "links" , [
235+ {
236+ rel : "items" ,
237+ href : `https://example.com/items?${ originalQuery } ` ,
238+ type : "application/geo+json" ,
239+ title : "Collection Items" ,
240+ } ,
241+ ] ) ;
242+ } ) ;
206243} ) ;
207244
208245describe ( "generateBaseUrlForCollection for cloudstac/ALL" , ( ) => {
0 commit comments