[Routing] fix router base url when default uri has trailing slash #46097
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.
When the router default uri (feature #36651) has a trailing slash, the generated URLs are wrong. E.g.
Generating any absolute URL given this base path currently resulted in double slashes, e.g.
https://example.org//mypage
because the base url is set to
/
and the path info defaults to/
as well. This is not correct and will result in a 404.The most consistent fix with the rest of symfony is to always rtrim the trailing slashes from the base url.
This is already done in the HttpFoundation Request class see
symfony/src/Symfony/Component/HttpFoundation/Request.php
Line 849 in 674ad07
So I think it makes sense to enforce this also on the requestcontext so it is also the case when it does not go through the fromRequest but via fromUri in the CLI.