Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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

Merged

Conversation

@Tobion
Copy link
Contributor

QA
Branch?5.4
Bug fix?yes
New feature?no
Deprecations?no
Tickets
LicenseMIT
Doc PR

When the router default uri (feature#36651) has a trailing slash, the generated URLs are wrong. E.g.

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

* The base URL never ends with a /.

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.

$this->assertSame('test.com',$requestContext->getHost());
$this->assertSame(8080,$requestContext->getHttpPort());
$this->assertSame(443,$requestContext->getHttpsPort());
$this->assertSame('',$requestContext->getBaseUrl());
Copy link
ContributorAuthor

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.

@TobionTobionforce-pushed thefix-base-url-trailing-slash branch from5b9b708 tod60a6b8CompareApril 18, 2022 19:44
@TobionTobionforce-pushed thefix-base-url-trailing-slash branch fromd60a6b8 to07136a9CompareApril 18, 2022 21:45
@nicolas-grekas
Copy link
Member

Shouldn't this target 4.4?

@Tobion
Copy link
ContributorAuthor

Well in Symfony the problem is only exposed since the default_uri config which was introduced in 5.x
The fromUri method does not exist in 4.4.

@nicolas-grekas
Copy link
Member

Thank you@Tobion.

@nicolas-grekasnicolas-grekas merged commitc14d0a1 intosymfony:5.4Apr 19, 2022
@TobionTobion deleted the fix-base-url-trailing-slash branchApril 19, 2022 08:59
This was referencedApr 27, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

3 participants

@Tobion@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp