Fixing issue where actions starting with a prefix but not followed by an _ would get mangled when going through router::url().

Fixes #1556
This commit is contained in:
mark_story 2011-02-24 16:43:13 -05:00
parent 139d6b3133
commit e05c6cd83f
2 changed files with 5 additions and 1 deletions

View file

@ -822,7 +822,7 @@ class Router {
} elseif (isset($url[$prefix]) && !$url[$prefix]) {
unset($url[$prefix]);
}
if (isset($url[$prefix]) && strpos($url['action'], $prefix) === 0) {
if (isset($url[$prefix]) && strpos($url['action'], $prefix . '_') === 0) {
$url['action'] = substr($url['action'], strlen($prefix) + 1);
}
}

View file

@ -1513,6 +1513,10 @@ class RouterTest extends CakeTestCase {
$result = Router::url(array('action' => 'protected_edit', 1, 'protected' => true));
$expected = '/protected/images/edit/1';
$this->assertEqual($result, $expected);
$result = Router::url(array('action' => 'protectededit', 1, 'protected' => true));
$expected = '/protected/images/protectededit/1';
$this->assertEqual($result, $expected);
$result = Router::url(array('action' => 'edit', 1, 'protected' => true));
$expected = '/protected/images/edit/1';