From b5bc60c51c3a1ca4640d38ec264c72c9082c4afc Mon Sep 17 00:00:00 2001 From: Patrick Leary Date: Wed, 24 Dec 2025 11:18:27 -0500 Subject: [PATCH] fix: modify cache key when per_page is zero, WEB-889 --- lib/util.js | 3 ++- test/util.js | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/util.js b/lib/util.js index 5c07903f..10953f68 100644 --- a/lib/util.js +++ b/lib/util.js @@ -430,7 +430,8 @@ const util = class util { cacheableParams.qualityGrade = queryDup.quality_grade ? queryDup.quality_grade : null; cacheableParams.spam = queryDup.spam ? queryDup.spam : null; cacheableParams.captive = queryDup.captive ? queryDup.captive : null; - cacheableParams.perPage = queryDup.per_page ? queryDup.per_page : null; + cacheableParams.perPage = ( _.isNumber( queryDup.per_page ) || queryDup.per_page ) + ? queryDup.per_page : null; cacheableParams.order = queryDup.order ? queryDup.order : null; cacheableParams.orderBy = queryDup.order_by ? queryDup.order_by : null; cacheableParams.returnBounds = queryDup.return_bounds ? queryDup.return_bounds : null; diff --git a/test/util.js b/test/util.js index 990f1bb8..6a8a9800 100644 --- a/test/util.js +++ b/test/util.js @@ -194,6 +194,10 @@ describe( "util", ( ) => { expectParamInCacheKey( "place_id", 1, "placeID" ); } ); + it( "allows queries with numeric per_page value of 0 to be cached for obs search", ( ) => { + expectParamInCacheKey( "per_page", 0, "perPage" ); + } ); + it( "does not allow queries with place_id to be cached for obs search when logged in", ( ) => { const req = { query: {