Skip to content

Commit

Permalink
Fix missing inflection on prefix value.
Browse files Browse the repository at this point in the history
Routing prefix value names need to be underscored so that they are
compatible with previous behavior and namespace generation.

Refs #10037
  • Loading branch information
markstory committed Jan 16, 2017
1 parent b40d205 commit a3298a4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Routing/Router.php
Expand Up @@ -990,9 +990,10 @@ public static function prefix($name, $params = [], $callback = null)
$callback = $params;
$params = [];
}
$name = Inflector::underscore($name);

if (empty($params['path'])) {
$path = '/' . Inflector::underscore($name);
$path = '/' . $name;
} else {
$path = $params['path'];
unset($params['path']);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Routing/RouterTest.php
Expand Up @@ -3108,7 +3108,7 @@ public function testPrefixOptions()
Router::prefix('CustomPath', ['path' => '/custom-path'], function ($routes) {
$this->assertInstanceOf('Cake\Routing\RouteBuilder', $routes);
$this->assertEquals('/custom-path', $routes->path());
$this->assertEquals(['prefix' => 'CustomPath'], $routes->params());
$this->assertEquals(['prefix' => 'custom_path'], $routes->params());
});
}

Expand Down

0 comments on commit a3298a4

Please sign in to comment.