-
Notifications
You must be signed in to change notification settings - Fork 351
Correct extension stripping #3757
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
Correct extension stripping #3757
Conversation
f96bdb2
to
f07930f
Compare
f07930f
to
51e72aa
Compare
51e72aa
to
0fa9b2b
Compare
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.
@jaapromijn thanks for contribution - this looks already promising and it works :) but there are some things missing:
- CHANGELOG.md entry
- At least one testcase in
Sulu\Bundle\SuluBundle\Tests\Unit\Routing\RouteProviderTest
which is able to cover this usecase
408dd31
to
2cfcea2
Compare
The removal of the extension of formats should only take place when the format is present as extension in the url. (sulu#3755)
Add tests and a changelog entry for the extension stripping. The removal of the extension of formats should only take place when the format is present as extension in the url. (sulu#3755)
2cfcea2
to
146c7d2
Compare
public function testGetRouteCollectionForRequestWithoutFormatExtension() | ||
{ | ||
$request = $this->prophesize(Request::class); | ||
$request->getPathInfo()->willReturn('/de/test'); |
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.
i think the reuqest will return /de/test.json
in a real-world example? didn't it?
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.
The use case is actually requesting a JSON page without using the .json
extension.
The requested url for example is:
https://www.example.com/en/articles/foo-bar
And in my own request analyser the request format is set to json:
$request->setRequestFormat('json');
So the path info should not return a path with a .json
extension in this case? What you describe is already covered in another test, I think.
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.
correct :) haven't recognized this - this PR is good! thanks for contribution
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.
👍 Thanks for the help!
The removal of the extension of formats should only take place when
the format is present as extension in the url. (#3755)
Why?
When using json as request format by default, without using .json extensions, the RouteProvider cut off the last character of the url, resulting in a 404.
In this PR, the stripping of the extension is only attempted if the format extension is present.