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
Expand Up @@ -756,11 +756,7 @@ function url($url = null, $full = false) {
}

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

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

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

//check that all the key names are in the url
$keyNames = array_flip($this->keys);
if (array_intersect_key($keyNames, $url) != $keyNames) {
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 (!$this->_greedy && array_diff_key($diff, $keyNames) != array()) {
Expand All @@ -1382,7 +1377,7 @@ function match($url) {
}
$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()) {
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.
Expand Down

0 comments on commit 02ed766

Please sign in to comment.