Skip to content

Commit

Permalink
Adding parameter pattern matching back into RouterRoute::match(), fix…
Browse files Browse the repository at this point in the history
…es failing tests in RouterRoute test case.
  • Loading branch information
markstory committed Nov 30, 2009
1 parent 5999264 commit e41c408
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions cake/libs/router.php
Expand Up @@ -1384,7 +1384,6 @@ function match($url) {
$passedArgsAndParams = array_diff_key($diff, $this->defaults, $keyNames);
list($named, $params) = Router::getNamedElements($passedArgsAndParams, $url['controller'], $url['action']);


//remove any pass params, they have numeric indexes
$pass = array();
$i = 0;
Expand All @@ -1393,8 +1392,16 @@ function match($url) {
unset($url[$i]);
$i++;
}
return $this->_writeUrl(array_merge($url, compact('pass', 'named', 'prefix')));

//check patterns for routed params
if (!empty($this->params)) {
foreach ($this->params as $key => $pattern) {
if (array_key_exists($key, $url) && !preg_match('#' . $pattern . '#', $url[$key])) {
return false;
}
}
}
return $this->_writeUrl(array_merge($url, compact('pass', 'named', 'prefix')));

//*/
/*
Expand Down Expand Up @@ -1426,12 +1433,7 @@ function match($url) {
unset($params[$key]);
}
}
debug($params);
list($named, $params) = Router::getNamedElements($params);
debug($named);
debug($params);
debug($this);
echo '-----------<br>';
if (!strpos($this->template, '*') && (!empty($pass) || !empty($named))) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion cake/tests/cases/libs/router.test.php
Expand Up @@ -1948,7 +1948,7 @@ function testRouterConnectDefaults() {
}
}

SimpleTest::ignore('RouterTest');
// SimpleTest::ignore('RouterTest');
// SimpleTest::ignore('RouterRouteTestCase');
/**
* Test case for RouterRoute
Expand Down

0 comments on commit e41c408

Please sign in to comment.