Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Routing] fix router base url when default uri has trailing slash#46097
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| $this->assertSame('test.com',$requestContext->getHost()); | ||
| $this->assertSame(8080,$requestContext->getHttpPort()); | ||
| $this->assertSame(443,$requestContext->getHttpsPort()); | ||
| $this->assertSame('',$requestContext->getBaseUrl()); |
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.
this is the main fix. all others are just adding missing test cases.
5b9b708 tod60a6b8Compared60a6b8 to07136a9Comparenicolas-grekas commentedApr 19, 2022
Shouldn't this target 4.4? |
Tobion commentedApr 19, 2022
Well in Symfony the problem is only exposed since the default_uri config which was introduced in 5.x |
nicolas-grekas commentedApr 19, 2022
Thank you@Tobion. |
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//mypagebecause 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 in674ad07
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.