[Routing] Fix PhpMatcherDump when url contains a . or a -

This commit is contained in:
Benjamin Lévêque 2010-12-22 09:41:53 +01:00 committed by Fabien Potencier
parent b2476719f6
commit 8a472b7d98
3 changed files with 8 additions and 1 deletions

View File

@ -61,7 +61,7 @@ class PhpMatcherDumper extends MatcherDumper
}
if (!count($compiledRoute->getVariables()) && false !== preg_match('#^(.)\^(?P<url>.*?)\$\1#', $compiledRoute->getRegex(), $m)) {
$conditions[] = sprintf("\$url === '%s'", $m['url']);
$conditions[] = sprintf("\$url === '%s'", str_replace('\\', '', $m['url']));
$matches = 'array()';
} else {

View File

@ -33,6 +33,10 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
return array_merge($this->mergeDefaults(array(), array ()), array('_route' => 'baz'));
}
if ($url === '/test/baz.html') {
return array_merge($this->mergeDefaults(array(), array ()), array('_route' => 'baz2'));
}
return false;
}
}

View File

@ -41,6 +41,9 @@ class PhpMatcherDumperTest extends \PHPUnit_Framework_TestCase
$collection->add('baz', new Route(
'/test/baz'
));
$collection->add('baz2', new Route(
'/test/baz.html'
));
$dumper = new PhpMatcherDumper($collection);
$this->assertStringEqualsFile(self::$fixturesPath.'/dumper/url_matcher1.php', $dumper->dump(), '->dump() dumps basic routes to the correct PHP file.');