Skip to content

Commit

Permalink
All tests passing in RouterTest.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Dec 2, 2009
1 parent e741e0e commit 02ed766
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions cake/libs/router.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -756,11 +756,7 @@ function url($url = null, $full = false) {
} }


$backupUrl = $url; $backupUrl = $url;
//$url += array('controller' => $params['controller'], 'plugin' => $params['plugin']) $url += array('controller' => $params['controller'], 'plugin' => $params['plugin']);
$url = array_merge(
array('controller' => $params['controller'], 'plugin' => $params['plugin']),
Set::filter($url, true)
);


if (isset($url['ext'])) { if (isset($url['ext'])) {
$extension = '.' . $url['ext']; $extension = '.' . $url['ext'];
Expand Down Expand Up @@ -1359,16 +1355,15 @@ function match($url) {
$defaults = $this->defaults; $defaults = $this->defaults;


if (isset($defaults['prefix'])) { if (isset($defaults['prefix'])) {
$prefix = $defaults['prefix']; $url['prefix'] = $defaults['prefix'];
unset($defaults['prefix']);
} }


//check that all the key names are in the url //check that all the key names are in the url
$keyNames = array_flip($this->keys); $keyNames = array_flip($this->keys);
if (array_intersect_key($keyNames, $url) != $keyNames) { if (array_intersect_key($keyNames, $url) != $keyNames) {
return false; return false;
} }
$diff = Set::diff($url, $defaults); $diff = Set::filter(Set::diff($url, $defaults), true);


//if a not a greedy route, no extra params are allowed. //if a not a greedy route, no extra params are allowed.
if (!$this->_greedy && array_diff_key($diff, $keyNames) != array()) { if (!$this->_greedy && array_diff_key($diff, $keyNames) != array()) {
Expand All @@ -1382,7 +1377,7 @@ function match($url) {
} }
$filteredDefaults = array_filter($defaults); $filteredDefaults = array_filter($defaults);


//if the difference between the url and defaults contains keys from defaults its not a match //if the difference between the url diff and defaults contains keys from defaults its not a match
if (array_intersect_key($filteredDefaults, $diff) !== array()) { if (array_intersect_key($filteredDefaults, $diff) !== array()) {
return false; return false;
} }
Expand Down Expand Up @@ -1424,7 +1419,7 @@ function match($url) {
} }
} }
} }
return $this->_writeUrl(array_merge($url, compact('pass', 'named', 'prefix'))); return $this->_writeUrl(array_merge($url, compact('pass', 'named')));
} }
/** /**
* Converts a matching route array into a url string. * Converts a matching route array into a url string.
Expand Down

0 comments on commit 02ed766

Please sign in to comment.