Skip to content

Bug: Routing placeholder in "controller"part of route doesn't work #2787

Description

@pbquet

Hello,
This route work

$routes->add('{locale}/admin/parameter/base/config/(:num)', 'Admin\Base::config/$1');

but in the following one, the first placeholder doesn't work because it is in the "controller" part of the route instead of "method" part :

$routes->add('{locale}/admin/parameter/(:segment)/config/(:num)', 'Admin\$1::config/$2');

and that's because the '\' before $1 escape the '$'

It's possible to resolve this issue in "system/Router/Router.php::checkRoutes" line 470 by changing :

$val = preg_replace('#^' . $key . '$#', $val, $uri);

to

$val = preg_replace('#^' . $key . '$#',  str_replace('\\', '\\\\', $val), $uri);

What do you think ?

CodeIgniter 4 version
4.02

Affected module(s)
Router/Router.php

Context

  • OS: Windows 10
  • Web server nginx 1.14
  • PHP 7.3.15

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixCurrent code behavior being reported or fixed is intentional and won't be changed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions