mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
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:
parent
003aaec870
commit
481cbf521e
2 changed files with 9 additions and 1 deletions
|
@ -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.
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Add table
Reference in a new issue