Skip to content

Commit

Permalink
Fixing issue where actions starting with a prefix but not followed by…
Browse files Browse the repository at this point in the history
… an _ would get mangled when going through router::url().

Fixes #1556
  • Loading branch information
markstory committed Feb 24, 2011
1 parent 139d6b3 commit e05c6cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cake/libs/router.php
Expand Up @@ -822,7 +822,7 @@ function url($url = null, $full = false) {
} elseif (isset($url[$prefix]) && !$url[$prefix]) { } elseif (isset($url[$prefix]) && !$url[$prefix]) {
unset($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); $url['action'] = substr($url['action'], strlen($prefix) + 1);
} }
} }
Expand Down
4 changes: 4 additions & 0 deletions cake/tests/cases/libs/router.test.php
Expand Up @@ -1513,6 +1513,10 @@ function testUrlGenerationWithAutoPrefixes() {
$result = Router::url(array('action' => 'protected_edit', 1, 'protected' => true)); $result = Router::url(array('action' => 'protected_edit', 1, 'protected' => true));
$expected = '/protected/images/edit/1'; $expected = '/protected/images/edit/1';
$this->assertEqual($result, $expected); $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)); $result = Router::url(array('action' => 'edit', 1, 'protected' => true));
$expected = '/protected/images/edit/1'; $expected = '/protected/images/edit/1';
Expand Down

0 comments on commit e05c6cd

Please sign in to comment.