diff --git a/cake/libs/router.php b/cake/libs/router.php index 44cdcca12..a990592dc 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -503,7 +503,7 @@ class Router extends Object { $args[] = $url[$keys[$i]]; } else if(!empty($path['namedArgs']) && in_array($keys[$i], array_keys($path['namedArgs'])) && !empty($url[$keys[$i]])) { $named[] = $keys[$i] . $path['argSeparator'] . $url[$keys[$i]]; - } else if(!empty($url[$keys[$i]])){ + } elseif(!empty($url[$keys[$i]]) || is_numeric($url[$keys[$i]])) { $named[] = $keys[$i] . $path['argSeparator'] . $url[$keys[$i]]; } } diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index df6b21dff..05898dab5 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -251,6 +251,18 @@ class RouterTest extends UnitTestCase { $result = $this->router->url(array('controller' => 'posts', 'action'=>'index', '0', '?' => array('var' => 'test', 'var2' => 'test2', 'more' => 'test data'))); $this->assertEqual($result, $expected); } + + function testNamedArgsUrlGeneration() { + Router::setRequestInfo(array(null, array('base' => '/', 'argSeparator' => ':'))); + + $result = $this->router->url(array('controller' => 'posts', 'action' => 'index', 'published' => 1, 'deleted' => 1)); + $expected = '/posts/index/published:1/deleted:1'; + $this->assertEqual($result, $expected); + + $result = $this->router->url(array('controller' => 'posts', 'action' => 'index', 'published' => 0, 'deleted' => 0)); + $expected = '/posts/index/published:0/deleted:0'; + $this->assertEqual($result, $expected); + } } ?> \ No newline at end of file