diff --git a/src/Application/Routers/Route.php b/src/Application/Routers/Route.php index 4fdcf99f1..3a5f61588 100644 --- a/src/Application/Routers/Route.php +++ b/src/Application/Routers/Route.php @@ -117,14 +117,14 @@ class Route extends Nette\Object implements Application\IRouter public function __construct($mask, $metadata = array(), $flags = 0) { if (is_string($metadata)) { - $a = strrpos($metadata, ':'); + $a = strrpos($tmp = $metadata, ':'); if (!$a) { throw new Nette\InvalidArgumentException("Second argument must be array or string in format Presenter:action, '$metadata' given."); } - $metadata = array( - self::PRESENTER_KEY => substr($metadata, 0, $a), - 'action' => $a === strlen($metadata) - 1 ? NULL : substr($metadata, $a + 1), - ); + $metadata = array(self::PRESENTER_KEY => substr($tmp, 0, $a)); + if ($a < strlen($tmp) - 1) { + $metadata['action'] = substr($tmp, $a + 1); + } } elseif ($metadata instanceof \Closure || $metadata instanceof Nette\Callback) { $metadata = array( self::PRESENTER_KEY => 'Nette:Micro', diff --git a/tests/Routers/Route.mandatoryAction.phpt b/tests/Routers/Route.mandatoryAction.phpt index 756b07fbf..92e93198b 100644 --- a/tests/Routers/Route.mandatoryAction.phpt +++ b/tests/Routers/Route.mandatoryAction.phpt @@ -19,3 +19,13 @@ testRouteIn($route, '/default', 'Default', array( 'action' => 'default', 'test' => 'testvalue', ), '/default?test=testvalue'); + +testRouteIn($route, '/', NULL); + + +$route = new Route('', 'Front:Default:'); + +testRouteIn($route, '/default', 'Front:Default', array( + 'action' => 'default', + 'test' => 'testvalue', +), '/default?test=testvalue');