[Routing] Fixed scheme redirecting for root path

This commit is contained in:
Jaroslav Kuba 2018-08-02 20:11:33 +02:00
parent f68cb81316
commit 2d7fdff021
16 changed files with 29 additions and 15 deletions

View File

@ -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";

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();