diff --git a/cake/libs/router.php b/cake/libs/router.php index 8567663be..616fcc0c5 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -751,6 +751,7 @@ class Router { unset($url[$prefix]); } } + if (array_key_exists('plugin', $url)) { $params['plugin'] = $url['plugin']; } @@ -774,6 +775,7 @@ class Router { if (isset($route->params['persist'], $params)) { $url = $route->persistParams($url, array_merge($params, $backupUrl)); } + if ($match = $route->match($url)) { $output = trim($match, '/'); $url = array(); @@ -1355,7 +1357,6 @@ class RouterRoute { $this->compile(); } $defaults = $this->defaults; - $url += $defaults; if (isset($defaults['prefix'])) { $prefix = $defaults['prefix']; @@ -1370,7 +1371,7 @@ class RouterRoute { $diff = Set::diff($url, $defaults); //if a not a greedy route, no extra params are allowed. - if (!$this->_greedy && array_keys($diff) != $this->keys) { + if (!$this->_greedy && array_diff_key($diff, $keyNames) != array()) { return false; } @@ -1413,7 +1414,6 @@ class RouterRoute { } } return $this->_writeUrl(array_merge($url, compact('pass', 'named', 'prefix'))); - //*/ /* $defaults = $this->defaults; @@ -1446,7 +1446,7 @@ class RouterRoute { } list($named, $params) = Router::getNamedElements($params); - if (!strpos($this->template, '*') && (!empty($pass) || !empty($named))) { + if (!$this->_greedy && (!empty($pass) || !empty($named))) { return false; } $routeParams = $this->keys; diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index 61d9aa114..662334ed3 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -966,7 +966,7 @@ class RouterTest extends CakeTestCase { array('controller' => 'posts', 'action' => 'index'), array('persist' => array('lang') )); - Router::connect('/:lang/:color/posts/edit/*', array('controller' => 'posts', 'action' => 'index')); + Router::connect('/:lang/:color/posts/edit/*', array('controller' => 'posts', 'action' => 'edit')); Router::connect('/about', array('controller' => 'pages', 'action' => 'view', 'about')); Router::parse('/en/red/posts/view/5');