Skip to content
Browse files

[Routing] removed trailing slash behavior on non-safe requests (refs #…

  • Loading branch information...
1 parent 16976be commit ed49e3be35b64fabc9dd643720aed96b0d9d2f33 @fabpot fabpot committed Jul 1, 2012
View
2 src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php
@@ -29,7 +29,7 @@ public function match($pathinfo)
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;
}
View
14 src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php
@@ -27,6 +27,20 @@ public function testRedirectWhenNoSlash()
$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();

0 comments on commit ed49e3b

Please sign in to comment.
Something went wrong with that request. Please try again.