-
-
Notifications
You must be signed in to change notification settings - Fork 937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(CompiledRouter): support URI templates with a trailing slash #1751
fix(CompiledRouter): support URI templates with a trailing slash #1751
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1751 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 52 52
Lines 4295 4295
Branches 690 690
=========================================
Hits 4295 4295
Continue to review full report at Codecov.
|
Regarding the question, the problem I see is that we cannot assume that an user has set the options before adding the routes. Also the options may be dynamically updated. |
Ah, good point wrt the configuration order @CaselIT ! Edit: these routes with trailing slashes might actually be reachable with middleware path rewrite though... 🤔 |
The documentation looks good 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is now possible to add two different routes for a path with and without a trailing forward slash
Is there a test for this specific use case? Otherwise LGTM. 👍
@kgriffs good point; I have now added a dedicated test to better exercise this scenario. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Summary of Changes
Previously, the default
CompiledRouter
was erroneously stripping trailing slashes from URI templates.This has been fixed so that it is now possible to add two different routes for a path with and without a trailing forward slash.
Related Issues
Closes #1544
Open Questions
I'm a bit divided what to do with
add_route()
in caseRequestOptions.strip_url_path_trailing_slash
is set toTrue
, and the provided template ends with a trailing slash?ValueError
asking to only add routes without a trailing slash (this may be a breaking change is someone had such a route).add_route()
.add_route()
, and emit a deprecation warning.I have now proceeded with the first option, documenting this as a breaking change, and sprinkling some warnings throughout the docs. Thanks @CaselIT for input!