[Routing] removed trailing slash behavior on non-safe requests (refs #2626)
This commit is contained in:
parent
16976be8ce
commit
ed49e3be35
@ -29,7 +29,7 @@ abstract class RedirectableUrlMatcher extends UrlMatcher implements Redirectable
|
||||
try {
|
||||
$parameters = parent::match($pathinfo);
|
||||
} catch (ResourceNotFoundException $e) {
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
if ('/' === substr($pathinfo, -1) || !in_array($this->context->getMethod(), array('HEAD', 'GET'))) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,20 @@ class RedirectableUrlMatcherTest extends \PHPUnit_Framework_TestCase
|
||||
$matcher->match('/foo');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Routing\Exception\ResourceNotFoundException
|
||||
*/
|
||||
public function testRedirectWhenNoSlashForNonSafeMethod()
|
||||
{
|
||||
$coll = new RouteCollection();
|
||||
$coll->add('foo', new Route('/foo/'));
|
||||
|
||||
$context = new RequestContext();
|
||||
$context->setMethod('POST');
|
||||
$matcher = $this->getMockForAbstractClass('Symfony\Component\Routing\Matcher\RedirectableUrlMatcher', array($coll, $context));
|
||||
$matcher->match('/foo');
|
||||
}
|
||||
|
||||
public function testSchemeRedirect()
|
||||
{
|
||||
$coll = new RouteCollection();
|
||||
|
Reference in New Issue
Block a user