Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[Routing] fix variable with a requirement of '0'

  • Loading branch information...
commit 02516de6521b3806b3708d6f0d1c8fe8be05f3a2 1 parent 1f5b793
@Tobion Tobion authored
View
2  src/Symfony/Component/Routing/RouteCompiler.php
@@ -42,7 +42,7 @@ public function compile(Route $route)
$pos = $match[0][1] + strlen($match[0][0]);
$var = $match[1][0];
- if ($req = $route->getRequirement($var)) {
+ if (null !== $req = $route->getRequirement($var)) {
$regexp = $req;
} else {
// Use the character preceding the variable as a separator
View
7 src/Symfony/Component/Routing/Tests/RouteCompilerTest.php
@@ -91,6 +91,13 @@ public function provideCompileData()
)),
array(
+ 'Route with a requirement of 0',
+ array('/{bar}', array('bar' => null), array('bar' => '0')),
+ '', '#^/(?<bar>0)?$#s', array('bar'), array(
+ array('variable', '/', '0', 'bar'),
+ )),
+
+ array(
'Route with an optional variable as the first segment with requirements',
array('/{bar}', array('bar' => 'bar'), array('bar' => '(foo|bar)')),
'', '#^/(?<bar>(foo|bar))?$#s', array('bar'), array(
Please sign in to comment.
Something went wrong with that request. Please try again.