Skip to content

Commit

Permalink
Merge pull request #3780 from nichwall/api_cache_case_insensitive
Browse files Browse the repository at this point in the history
API Cache Manager route uses case-insensitive match
  • Loading branch information
advplyr authored Jan 4, 2025
2 parents 5d1a17f + f70f214 commit f366dfa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions server/managers/ApiCacheManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
Expand Down
2 changes: 1 addition & 1 deletion server/routers/ApiRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit f366dfa

Please sign in to comment.