cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

URL with dashes "-" Not Routing

Open nesbert opened this issue 14 years ago • 1 comments

Hey Guys,

I tried updating the default router to handle "-" dashes the same way it handles "_" underscores. I overwrote the default routes with the following patterns fine and Phalcon finds the matches.

// set default routes with dashes
$router->add('#^/([a-zA-Z0-9\_\-]+)[/]{0,1}$#', array(
    'controller' => 1,
));
$router->add('#^/([a-zA-Z0-9\_\-]+)/([a-zA-Z0-9\_\-]+)(/.*)*$#', array(
    'controller' => 1,
    'action' => 2,
    'params' => 3,
));

But Phalcon does not translate the url segments to the expected controllers and actions:

Current:
/controller-dash -> Controller-dashController

Excepted:
/controller-dash -> ControllerDashController
/controller-dash/action-dash -> ControllerDashController::actionDashAction

It would be nice if this was possible.

Thanks in advance!

nesbert avatar Sep 26 '12 23:09 nesbert

Actually, this needs to be implemented in Phalcon\Text::camelize. Thanks for the suggestion

ghost avatar Sep 27 '12 00:09 ghost