API Cache Manager route uses case-insensitive match #3780
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Brief summary
Fix case-sensitive matching for API Cache Manager.
Which issue is fixed?
CodeQL issue from PR #3335.
Workflow output: https://github.com/advplyr/audiobookshelf/pull/3335/checks?check_run_id=35084757148
In-depth Description
#3335 (comment)
This PR changes the regex path matching to be case insensitive for the API Cache Manager. Two methods I found were to force all request URLs to be lowercase, or to ensure that the regex matches against a case-insensitive string. I chose to use case-insensitive matching for now due to some routes potentially being case sensitive, such as:
DELETE /api/tags/:tag
DELETE /api/genres/:genre
How have you tested this?
I changed various API calls in the web client to use various capitalization for library API endpoints and verified that everything was still routed correctly. The API Cache Manager continued to have cache hits and return data correctly.
Screenshots
N/A