[HttpFoundation] fixed Request::getFormat() when the mime-type has some optional parameter (closes #1235)
This commit is contained in:
parent
f16e206cd7
commit
0af4743583
@ -674,6 +674,10 @@ class Request
|
||||
*/
|
||||
public function getFormat($mimeType)
|
||||
{
|
||||
if (false !== $pos = strpos($mimeType, ';')) {
|
||||
$mimeType = substr($mimeType, 0, $pos);
|
||||
}
|
||||
|
||||
if (null === static::$formats) {
|
||||
static::initializeFormats();
|
||||
}
|
||||
|
@ -146,6 +146,15 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\HttpFoundation\Request::getFormat
|
||||
*/
|
||||
public function testGetFormatFromMimeTypeWithParameters()
|
||||
{
|
||||
$request = new Request();
|
||||
$this->assertEquals('json', $request->getFormat('application/json; charset=utf-8'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\HttpFoundation\Request::getMimeType
|
||||
* @dataProvider getFormatToMimeTypeMapProvider
|
||||
|
Reference in New Issue
Block a user