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: {