Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Commit 57c8ab5

Browse files
authored
Fix routes generate not working with names containing : (cakephp#18676)
1 parent 7f17d13 commit 57c8ab5

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/Command/RoutesGenerateCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ protected function _splitArgs(array $args): array
7878
$out = [];
7979
foreach ($args as $arg) {
8080
if (str_contains($arg, ':')) {
81-
[$key, $value] = explode(':', $arg);
81+
[$key, $value] = explode(':', $arg, 2);
8282
if (in_array($value, ['true', 'false'], true)) {
8383
$value = $value === 'true';
8484
}

tests/TestCase/Command/RoutesCommandTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,20 @@ public function testGenerateBoolParams(): void
299299
$this->assertOutputContains('> https://example.com/app/articles');
300300
}
301301

302+
public function testGenerateNameWithColon(): void
303+
{
304+
Configure::write('TestApp.routes', function ($routes): void {
305+
$routes->connect(
306+
'/example/update',
307+
['controller' => 'Example', 'action' => 'update'],
308+
['_name' => 'example:update'],
309+
);
310+
});
311+
$this->exec('routes generate _name:example:update');
312+
$this->assertExitCode(CommandInterface::CODE_SUCCESS);
313+
$this->assertOutputContains('> /example/update');
314+
}
315+
302316
/**
303317
* Test generating URLs
304318
*/

0 commit comments

Comments
 (0)