diff --git a/cake/libs/router.php b/cake/libs/router.php index d8448addb..855c4aaf7 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -1179,7 +1179,7 @@ class Router extends Object { $paths = Router::getPaths(); if (!empty($paths['base']) && stristr($url, $paths['base'])) { - $url = str_replace($paths['base'], '', $url); + $url = preg_replace("/{$paths['base']}/", '', $url, 1); } $url = '/' . $url; diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index 252a5c837..1b306ab35 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -266,6 +266,11 @@ class RouterTest extends CakeTestCase { $result = Router::normalize('/recipe/recipes/add'); $this->assertEqual($result, '/recipe/recipes/add'); + + Router::setRequestInfo(array(array(), array('base' => 'us'))); + $result = Router::normalize('/us/users/logout/'); + $this->assertEqual($result, '/users/logout'); + } /** * testUrlGeneration method