-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Inappropriate delimiter used in fillRouteParams #2353
Comments
I'm having problems recreating this one.
public function index($val = null)
{
dd($val);
return view('welcome_message');
}
What am I missing? |
@korgoth can you provide any more insight? |
Hello, @lonnieezell . Sorry for the delay but i am heavily on road last month. After your first reply i made some more tests on my side and it seems that you are indeed correct. Having only this one route setup - things are working as expected. It turns out however, that my setup is a bit more complex and thats whats raising the exceptions. Here are some more details: I wanted to have a (:any) route, setup as my last route, that captures everything thats not defined and sends it to a controller. Thats why i had to define a / controller to act as a home.
having it setup like this indeed produces correct results for (a|b|c) but throws an exception at /
Now it might be that ive misunderstood how routing works, if so - please tell me what am i getting wrong. |
Sorry it took so long. Still can't recreate, though. Used these routes:
And this controller:
Going to |
Describe the bug
Trying to use a simple regex in the routes config file such as (a|b|c) results in an ErrorException being thrown at SYSTEMPATH/Router/RouteCollection.php at line 1331 with the error of
preg_match(): Unknown modifier
Upon investigation i see that the fillRouteParams function is trying to preg_match using pipe (|) as a delimiter, which is not appropriate as the pipe is often used in regular expressions.
CodeIgniter 4 version
rc.3
Affected module(s)
Router
Reverse routing
Expected behavior, and steps to reproduce if appropriate
I expected
$route->get('(a|b|c)', "Controller::index/$1", ['as' => 'testname']);
To result in calling Controller:index with either a, b or c passed as first parameter.
The excption is thrown as soon as the route config files is being read.
P.S. I also tried escaping the pipe using \| but that resulted in
CodeIgniter\Router\Exceptions\RouterException
thrown in SYSTEMPATH/Router/Exceptions/RouterException.php at line 10The text was updated successfully, but these errors were encountered: