Adding fixes to Router::normalize() when called with empty parameter (Ticket #3734)

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6152 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2007-12-14 15:09:05 +00:00
parent 003aaec870
commit 481cbf521e
2 changed files with 9 additions and 1 deletions

View file

@ -1034,7 +1034,12 @@ class Router extends Object {
while (strpos($url, '//') !== false) {
$url = str_replace('//', '/', $url);
}
return preg_replace('/(\/$)/', '', $url);
$url = preg_replace('/(\/$)/', '', $url);
if (empty($url)) {
return '/';
}
return $url;
}
/**
* Returns the route matching the current request URL.

View file

@ -137,6 +137,9 @@ class RouterTest extends UnitTestCase {
$result = $this->router->normalize(array('controller' => 'users', 'action' => 'logout'));
$this->assertEqual($result, $expected);
$result = $this->router->normalize('/');
$this->assertEqual($result, '/');
}
function testUrlGeneration() {