Browse files

fixes #5978, Router::normalize url generation

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7981 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information...
1 parent ff340d3 commit 52318f9d17c8b5c7a1ba838fadd07e9457041a89 gwoo committed Jan 14, 2009
Showing with 6 additions and 1 deletion.
  1. +1 −1 cake/libs/router.php
  2. +5 −0 cake/tests/cases/libs/router.test.php
View
2 cake/libs/router.php
@@ -1179,7 +1179,7 @@ function normalize($url = '/') {
$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;
View
5 cake/tests/cases/libs/router.test.php
@@ -266,6 +266,11 @@ function testUrlNormalization() {
$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

0 comments on commit 52318f9

Please sign in to comment.