[Routing] fixed tests

This commit is contained in:
Fabien Potencier 2017-12-14 11:33:46 -08:00
parent 13f58b403c
commit f5f3dd7878
4 changed files with 23 additions and 23 deletions

View File

@ -15,10 +15,10 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
$this->context = $context; $this->context = $context;
} }
public function match($pathinfo) public function match($rawPathinfo)
{ {
$allow = array(); $allow = array();
$pathinfo = rawurldecode($pathinfo); $pathinfo = rawurldecode($rawPathinfo);
$trimmedPathinfo = rtrim($pathinfo, '/'); $trimmedPathinfo = rtrim($pathinfo, '/');
$context = $this->context; $context = $this->context;
$request = $this->request; $request = $this->request;

View File

@ -15,10 +15,10 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
$this->context = $context; $this->context = $context;
} }
public function match($pathinfo) public function match($rawPathinfo)
{ {
$allow = array(); $allow = array();
$pathinfo = rawurldecode($pathinfo); $pathinfo = rawurldecode($rawPathinfo);
$trimmedPathinfo = rtrim($pathinfo, '/'); $trimmedPathinfo = rtrim($pathinfo, '/');
$context = $this->context; $context = $this->context;
$request = $this->request; $request = $this->request;
@ -57,7 +57,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
// a_fourth // a_fourth
if ('/a/44' === $trimmedPathinfo) { if ('/a/44' === $trimmedPathinfo) {
if (substr($pathinfo, -1) !== '/') { if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', 'a_fourth'); return $this->redirect($rawPathinfo.'/', 'a_fourth');
} }
return array('_route' => 'a_fourth'); return array('_route' => 'a_fourth');
@ -66,7 +66,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
// a_fifth // a_fifth
if ('/a/55' === $trimmedPathinfo) { if ('/a/55' === $trimmedPathinfo) {
if (substr($pathinfo, -1) !== '/') { if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', 'a_fifth'); return $this->redirect($rawPathinfo.'/', 'a_fifth');
} }
return array('_route' => 'a_fifth'); return array('_route' => 'a_fifth');
@ -75,7 +75,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
// a_sixth // a_sixth
if ('/a/66' === $trimmedPathinfo) { if ('/a/66' === $trimmedPathinfo) {
if (substr($pathinfo, -1) !== '/') { if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', 'a_sixth'); return $this->redirect($rawPathinfo.'/', 'a_sixth');
} }
return array('_route' => 'a_sixth'); return array('_route' => 'a_sixth');
@ -92,7 +92,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
// nested_a // nested_a
if ('/nested/group/a' === $trimmedPathinfo) { if ('/nested/group/a' === $trimmedPathinfo) {
if (substr($pathinfo, -1) !== '/') { if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', 'nested_a'); return $this->redirect($rawPathinfo.'/', 'nested_a');
} }
return array('_route' => 'nested_a'); return array('_route' => 'nested_a');
@ -101,7 +101,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
// nested_b // nested_b
if ('/nested/group/b' === $trimmedPathinfo) { if ('/nested/group/b' === $trimmedPathinfo) {
if (substr($pathinfo, -1) !== '/') { if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', 'nested_b'); return $this->redirect($rawPathinfo.'/', 'nested_b');
} }
return array('_route' => 'nested_b'); return array('_route' => 'nested_b');
@ -110,7 +110,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
// nested_c // nested_c
if ('/nested/group/c' === $trimmedPathinfo) { if ('/nested/group/c' === $trimmedPathinfo) {
if (substr($pathinfo, -1) !== '/') { if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', 'nested_c'); return $this->redirect($rawPathinfo.'/', 'nested_c');
} }
return array('_route' => 'nested_c'); return array('_route' => 'nested_c');
@ -122,7 +122,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
// slashed_a // slashed_a
if ('/slashed/group' === $trimmedPathinfo) { if ('/slashed/group' === $trimmedPathinfo) {
if (substr($pathinfo, -1) !== '/') { if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', 'slashed_a'); return $this->redirect($rawPathinfo.'/', 'slashed_a');
} }
return array('_route' => 'slashed_a'); return array('_route' => 'slashed_a');
@ -131,7 +131,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
// slashed_b // slashed_b
if ('/slashed/group/b' === $trimmedPathinfo) { if ('/slashed/group/b' === $trimmedPathinfo) {
if (substr($pathinfo, -1) !== '/') { if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', 'slashed_b'); return $this->redirect($rawPathinfo.'/', 'slashed_b');
} }
return array('_route' => 'slashed_b'); return array('_route' => 'slashed_b');
@ -140,7 +140,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
// slashed_c // slashed_c
if ('/slashed/group/c' === $trimmedPathinfo) { if ('/slashed/group/c' === $trimmedPathinfo) {
if (substr($pathinfo, -1) !== '/') { if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', 'slashed_c'); return $this->redirect($rawPathinfo.'/', 'slashed_c');
} }
return array('_route' => 'slashed_c'); return array('_route' => 'slashed_c');

View File

@ -15,10 +15,10 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
$this->context = $context; $this->context = $context;
} }
public function match($pathinfo) public function match($rawPathinfo)
{ {
$allow = array(); $allow = array();
$pathinfo = rawurldecode($pathinfo); $pathinfo = rawurldecode($rawPathinfo);
$trimmedPathinfo = rtrim($pathinfo, '/'); $trimmedPathinfo = rtrim($pathinfo, '/');
$context = $this->context; $context = $this->context;
$request = $this->request; $request = $this->request;

View File

@ -15,10 +15,10 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
$this->context = $context; $this->context = $context;
} }
public function match($pathinfo) public function match($rawPathinfo)
{ {
$allow = array(); $allow = array();
$pathinfo = rawurldecode($pathinfo); $pathinfo = rawurldecode($rawPathinfo);
$trimmedPathinfo = rtrim($pathinfo, '/'); $trimmedPathinfo = rtrim($pathinfo, '/');
$context = $this->context; $context = $this->context;
$request = $this->request; $request = $this->request;
@ -34,7 +34,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
// simple_trailing_slash_no_methods // simple_trailing_slash_no_methods
if ('/trailing/simple/no-methods' === $trimmedPathinfo) { if ('/trailing/simple/no-methods' === $trimmedPathinfo) {
if (substr($pathinfo, -1) !== '/') { if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', 'simple_trailing_slash_no_methods'); return $this->redirect($rawPathinfo.'/', 'simple_trailing_slash_no_methods');
} }
return array('_route' => 'simple_trailing_slash_no_methods'); return array('_route' => 'simple_trailing_slash_no_methods');
@ -48,7 +48,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
} }
if (substr($pathinfo, -1) !== '/') { if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', 'simple_trailing_slash_GET_method'); return $this->redirect($rawPathinfo.'/', 'simple_trailing_slash_GET_method');
} }
return array('_route' => 'simple_trailing_slash_GET_method'); return array('_route' => 'simple_trailing_slash_GET_method');
@ -63,7 +63,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
} }
if (substr($pathinfo, -1) !== '/') { if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', 'simple_trailing_slash_HEAD_method'); return $this->redirect($rawPathinfo.'/', 'simple_trailing_slash_HEAD_method');
} }
return array('_route' => 'simple_trailing_slash_HEAD_method'); return array('_route' => 'simple_trailing_slash_HEAD_method');
@ -87,7 +87,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
// regex_trailing_slash_no_methods // regex_trailing_slash_no_methods
if (0 === strpos($pathinfo, '/trailing/regex/no-methods') && preg_match('#^/trailing/regex/no\\-methods/(?P<param>[^/]++)/?$#s', $pathinfo, $matches)) { if (0 === strpos($pathinfo, '/trailing/regex/no-methods') && preg_match('#^/trailing/regex/no\\-methods/(?P<param>[^/]++)/?$#s', $pathinfo, $matches)) {
if (substr($pathinfo, -1) !== '/') { if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', 'regex_trailing_slash_no_methods'); return $this->redirect($rawPathinfo.'/', 'regex_trailing_slash_no_methods');
} }
return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_no_methods')), array ()); return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_no_methods')), array ());
@ -101,7 +101,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
} }
if (substr($pathinfo, -1) !== '/') { if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', 'regex_trailing_slash_GET_method'); return $this->redirect($rawPathinfo.'/', 'regex_trailing_slash_GET_method');
} }
return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_GET_method')), array ()); return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_GET_method')), array ());
@ -116,7 +116,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
} }
if (substr($pathinfo, -1) !== '/') { if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', 'regex_trailing_slash_HEAD_method'); return $this->redirect($rawPathinfo.'/', 'regex_trailing_slash_HEAD_method');
} }
return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_HEAD_method')), array ()); return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_HEAD_method')), array ());