Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 02516de

Browse files
committed
[Routing] fix variable with a requirement of '0'
1 parent 1f5b793 commit 02516de

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Symfony/Component/Routing/RouteCompiler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function compile(Route $route)
4242
$pos = $match[0][1] + strlen($match[0][0]);
4343
$var = $match[1][0];
4444

45-
if ($req = $route->getRequirement($var)) {
45+
if (null !== $req = $route->getRequirement($var)) {
4646
$regexp = $req;
4747
} else {
4848
// Use the character preceding the variable as a separator

src/Symfony/Component/Routing/Tests/RouteCompilerTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ public function provideCompileData()
9090
array('variable', '/', '[^/]+', 'bar'),
9191
)),
9292

93+
array(
94+
'Route with a requirement of 0',
95+
array('/{bar}', array('bar' => null), array('bar' => '0')),
96+
'', '#^/(?<bar>0)?$#s', array('bar'), array(
97+
array('variable', '/', '0', 'bar'),
98+
)),
99+
93100
array(
94101
'Route with an optional variable as the first segment with requirements',
95102
array('/{bar}', array('bar' => 'bar'), array('bar' => '(foo|bar)')),

0 commit comments

Comments
 (0)