cloudinary-community / cloudinary-util

https://cloudinary-util.vercel.app
MIT License
12 stars 19 forks source link

Fix code scanning alert no. 2: Inefficient regular expression #204

Closed colbyfayock closed 1 month ago

colbyfayock commented 2 months ago

Fixes https://github.com/cloudinary-community/cloudinary-util/security/code-scanning/2

To fix the problem, we need to modify the regular expression to remove the ambiguity that causes exponential backtracking. Specifically, we should replace the optional segments (\/?) with a more deterministic pattern. This can be achieved by ensuring that each segment of the regular expression is unambiguous and does not lead to multiple matching paths.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.