From a6fd0c95b2a83703e12b079c65f9399d139b3aea Mon Sep 17 00:00:00 2001 From: Nicholas Wallace Date: Thu, 2 Jan 2025 20:07:21 -0700 Subject: [PATCH 1/2] API cache manager case-insensitive match --- server/routers/ApiRouter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/routers/ApiRouter.js b/server/routers/ApiRouter.js index 235d25cd..a4239745 100644 --- a/server/routers/ApiRouter.js +++ b/server/routers/ApiRouter.js @@ -65,7 +65,7 @@ class ApiRouter { // // Library Routes // - this.router.get(/^\/libraries/, this.apiCacheManager.middleware) + this.router.get(/^\/libraries/i, this.apiCacheManager.middleware) this.router.post('/libraries', LibraryController.create.bind(this)) this.router.get('/libraries', LibraryController.findAll.bind(this)) this.router.get('/libraries/:id', LibraryController.middleware.bind(this), LibraryController.findOne.bind(this)) From f70f21455f773e54494650a07688117febbc134a Mon Sep 17 00:00:00 2001 From: Nicholas Wallace Date: Thu, 2 Jan 2025 20:13:38 -0700 Subject: [PATCH 2/2] Req URL is lowercase in ApiCacheManager --- server/managers/ApiCacheManager.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/managers/ApiCacheManager.js b/server/managers/ApiCacheManager.js index 35009447..81b58c99 100644 --- a/server/managers/ApiCacheManager.js +++ b/server/managers/ApiCacheManager.js @@ -42,6 +42,8 @@ class ApiCacheManager { Logger.debug(`[ApiCacheManager] Skipping cache for random sort`) return next() } + // Force URL to be lower case for matching against routes + req.url = req.url.toLowerCase() const key = { user: req.user.username, url: req.url } const stringifiedKey = JSON.stringify(key) Logger.debug(`[ApiCacheManager] count: ${this.cache.size} size: ${this.cache.calculatedSize}`)