Permalink
Browse files

Fixing issue where actions starting with a prefix but not followed by…

… an _ would get mangled when going through router::url().


Fixes #1556
  • Loading branch information...
1 parent 139d6b3 commit e05c6cd83fb35ac2f25234147309776f39fb2556 @markstory markstory committed Feb 24, 2011
Showing with 5 additions and 1 deletion.
  1. +1 −1 cake/libs/router.php
  2. +4 −0 cake/tests/cases/libs/router.test.php
View
@@ -822,7 +822,7 @@ function url($url = null, $full = false) {
} 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);
}
}
@@ -1513,6 +1513,10 @@ function testUrlGenerationWithAutoPrefixes() {
$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';

0 comments on commit e05c6cd

Please sign in to comment.