From 68084d9f675869daf0029fd42ddc79c57d8a722c Mon Sep 17 00:00:00 2001 From: Alexandr Garbuzov Date: Sun, 7 Sep 2025 20:43:59 +0300 Subject: [PATCH] fix: return cache seconds value clamping which was accidentally removed in cdc6ad1 (#4379) --- api/top-langs.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/api/top-langs.js b/api/top-langs.js index fe5fb4af..1c7ed681 100644 --- a/api/top-langs.js +++ b/api/top-langs.js @@ -1,6 +1,7 @@ import { renderTopLanguages } from "../src/cards/top-languages.js"; import { blacklist } from "../src/common/blacklist.js"; import { + clampValue, CONSTANTS, parseArray, parseBoolean, @@ -69,9 +70,10 @@ export default async (req, res) => { count_weight, ); - let cacheSeconds = parseInt( - cache_seconds || CONSTANTS.TOP_LANGS_CACHE_SECONDS, - 10, + let cacheSeconds = clampValue( + parseInt(cache_seconds || CONSTANTS.TOP_LANGS_CACHE_SECONDS, 10), + CONSTANTS.TWO_DAY, + CONSTANTS.TEN_DAY, ); cacheSeconds = process.env.CACHE_SECONDS ? parseInt(process.env.CACHE_SECONDS, 10) || cacheSeconds