Closed Cali93 closed 1 year ago
Taking a look now, but gotta warn you - no promises on that one. You're using undocumented (and not officially supported) syntax that happened to work before, but certainly not by plan :) Basically some regex works by happy accident, but others get mangled in the rewrite process - just depends on what characters/patterns you're using!
If I can make it work for you though, I will, because I think that's a pretty cool switching syntax...
So, 4.0.14
should have test coverage in place to verify your functionality, and it should have been restored :)
Amazing, thanks a lot! 🚢
Describe the Issue
In previous versions (3.x and lower) it was possible to have optional route paths using the following pattern
/(api?)/v1/my-route
. So making a GET request on both/api/v1/my-route
and/v1/my-route
would work and would be handled as expected. However v4 introduces a breaking change as the optional path isn't supported anymore.Example Router Code
Please provide the itty-router code related to the issue. If possible, create a minimal, reproducible example.
Request Details
Steps to Reproduce
Steps to reproduce the behavior:
router.get('(/api)?/v1/:something', getSomething)
/api/v1/my-route
or/v1/my-route
Expected Behavior
Making a request to both
/api/v1/my-route
and/v1/my-route
should work as it is on 2.x and 3.x for the following route/(api?)/v1/my-route
Actual Behavior
Environment (please complete the following information):
Additional Context
Add any other context about the problem here.