[Routing] Fixed scheme redirecting for root path
This commit is contained in:
parent
f68cb81316
commit
2d7fdff021
@ -194,7 +194,7 @@ EOF
|
||||
}
|
||||
|
||||
// used to display the Welcome Page in apps that don't define a homepage
|
||||
$code .= " if ('/' === \$pathinfo && !\$allow) {\n";
|
||||
$code .= " if ('/' === \$pathinfo && !\$allow && !\$allowSchemes) {\n";
|
||||
$code .= " throw new Symfony\Component\Routing\Exception\NoConfigurationException();\n";
|
||||
$code .= " }\n";
|
||||
|
||||
|
@ -26,7 +26,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
if ('/' === $pathinfo && !$allow && !$allowSchemes) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
$offset += strlen($m);
|
||||
}
|
||||
}
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
if ('/' === $pathinfo && !$allow && !$allowSchemes) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
|
@ -2821,7 +2821,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
$offset += strlen($m);
|
||||
}
|
||||
}
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
if ('/' === $pathinfo && !$allow && !$allowSchemes) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
||||
$offset += strlen($m);
|
||||
}
|
||||
}
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
if ('/' === $pathinfo && !$allow && !$allowSchemes) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
$offset += strlen($m);
|
||||
}
|
||||
}
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
if ('/' === $pathinfo && !$allow && !$allowSchemes) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
$offset += strlen($m);
|
||||
}
|
||||
}
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
if ('/' === $pathinfo && !$allow && !$allowSchemes) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
|
@ -275,7 +275,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
||||
$offset += strlen($m);
|
||||
}
|
||||
}
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
if ('/' === $pathinfo && !$allow && !$allowSchemes) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
$offset += strlen($m);
|
||||
}
|
||||
}
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
if ('/' === $pathinfo && !$allow && !$allowSchemes) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
return $ret;
|
||||
}
|
||||
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
if ('/' === $pathinfo && !$allow && !$allowSchemes) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
||||
$offset += strlen($m);
|
||||
}
|
||||
}
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
if ('/' === $pathinfo && !$allow && !$allowSchemes) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
$offset += strlen($m);
|
||||
}
|
||||
}
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
if ('/' === $pathinfo && !$allow && !$allowSchemes) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
||||
$offset += strlen($m);
|
||||
}
|
||||
}
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
if ('/' === $pathinfo && !$allow && !$allowSchemes) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
$offset += strlen($m);
|
||||
}
|
||||
}
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
if ('/' === $pathinfo && !$allow && !$allowSchemes) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
break;
|
||||
}
|
||||
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
if ('/' === $pathinfo && !$allow && !$allowSchemes) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
|
@ -93,6 +93,20 @@ class RedirectableUrlMatcherTest extends UrlMatcherTest
|
||||
$this->assertEquals(array('_route' => 'foo', 'bar' => 'baz', 'redirect' => 'value'), $matcher->match('/foo/baz'));
|
||||
}
|
||||
|
||||
public function testSchemeRedirectForRoot()
|
||||
{
|
||||
$coll = new RouteCollection();
|
||||
$coll->add('foo', new Route('/', array(), array(), array(), '', array('https')));
|
||||
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
$matcher
|
||||
->expects($this->once())
|
||||
->method('redirect')
|
||||
->with('/', 'foo', 'https')
|
||||
->will($this->returnValue(array('redirect' => 'value')));
|
||||
$this->assertEquals(array('_route' => 'foo', 'redirect' => 'value'), $matcher->match('/'));
|
||||
}
|
||||
|
||||
public function testSlashRedirectWithParams()
|
||||
{
|
||||
$coll = new RouteCollection();
|
||||
|
Reference in New Issue
Block a user