feat: support parameter patterns
I'm planning to move to the newer version of path-to-regexp. In our codebase heavily relies on regex for parameter validation, especially in some legacy components we still have running in production.
I stumbled across this comment that mentions parameter pattern support might be coming in future versions. Based on that, I went ahead and implemented the functionality in this PR.
Feel free to ignore this PR if it doesn't align with the project's direction. I understand you may have different plans for handling parameter patterns in future versions!
@Kakulukian I wanted to let you know ASAP that I really appreciate the PR! It is the right direction, but unfortunately it's even more involved than this because I want to add it back in a way that ensures it still generates safe regexes. That sadly means more of a regex parser.
The good news, if you're interested, is that we could start with a very simple "parser" by rejecting all meta characters except |. Then add other use-cases one by one. Would that work for you?
Assuming you're up for it, I'll also separately leave some review comments.
@Kakulukian I wanted to let you know ASAP that I really appreciate the PR! It is the right direction, but unfortunately it's even more involved than this because I want to add it back in a way that ensures it still generates safe regexes. That sadly means more of a regex parser.
The good news, if you're interested, is that we could start with a very simple "parser" by rejecting all meta characters except
|. Then add other use-cases one by one. Would that work for you?Assuming you're up for it, I'll also separately leave some review comments.
That's ok for me, updated with your suggestions :)
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 98.17%. Comparing base (26d87a2) to head (eaf19ce).
:warning: Report is 40 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #362 +/- ##
===========================================
- Coverage 100.00% 98.17% -1.83%
===========================================
Files 1 1
Lines 668 439 -229
Branches 151 155 +4
===========================================
- Hits 668 431 -237
- Misses 0 8 +8
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.