You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #46097 [Routing] fix router base url when default uri has trailing slash (Tobion)
This PR was merged into the 5.4 branch.
Discussion
----------
[Routing] fix router base url when default uri has trailing slash
| Q | A
| ------------- | ---
| Branch? | 5.4
| Bug fix? | yes
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets |
| License | MIT
| Doc PR |
When the router default uri (feature #36651) has a trailing slash, the generated URLs are wrong. E.g.
```yaml
framework:
router:
default_uri: 'https://example.org/' # this is equivalent URI to 'https://example.org'
```
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 https://github.com/symfony/symfony/blob/674ad07a684fe1274ae49d9f4b6294ede3b47b92/src/Symfony/Component/HttpFoundation/Request.php#L849
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.
Commits
-------
07136a9 [Routing] fix router base url when default uri has trailing slash
0 commit comments