From dee2ea4f6881180648570966fad98a1e086c0c81 Mon Sep 17 00:00:00 2001 From: nate Date: Fri, 27 Jul 2007 13:32:26 +0000 Subject: [PATCH] Updating fix for empty parameter passing in Router; adding test case git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5470 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/router.php | 8 ++++---- cake/tests/cases/libs/router.test.php | 11 +++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/cake/libs/router.php b/cake/libs/router.php index cd91efd69..64f8ed492 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -333,10 +333,10 @@ class Router extends Object { break; //leave the default values; } else { // unnamed elements go in as 'pass' - $search = explode('/', $found); - foreach (Set::filter($search, true) as $k => $value) { - $out['pass'][$k] = $_this->stripEscape($value); - } + $out['pass'] = am($out['pass'], array_map( + array(&$_this, 'stripEscape'), + Set::filter(explode('/', $found), true) + )); } } break; diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index a01e88d06..818378f91 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -249,6 +249,17 @@ class RouterTest extends UnitTestCase { $result = $this->router->parse('/posts/2007/08/01/title-of-post-here'); $expected = array('year' => '2007', 'month' => '08', 'day' => '01', 'controller' => 'posts', 'action' => 'view', 'plugin' =>'', 'pass' => array('0' => 'title-of-post-here')); $this->assertEqual($result, $expected); + + $this->router->routes = array(); + $result = $this->router->parse('/pages/display/home'); + $expected = array('pass' => array ('home'), 'controller' => 'pages', 'action' => 'display'); + $this->assertEqual($result, $expected); + + $result = $this->router->parse('pages/display/home/'); + $this->assertEqual($result, $expected); + + $result = $this->router->parse('pages/display/home'); + $this->assertEqual($result, $expected); } function testAdminRouting() {