simplified regex for route creation
This commit is contained in:
parent
7e19efd420
commit
d2cdcdded4
|
@ -44,7 +44,7 @@ class Router
|
||||||
$parameters = $matches[0];
|
$parameters = $matches[0];
|
||||||
|
|
||||||
// create regex for route:
|
// create regex for route:
|
||||||
$regex = preg_replace(pattern: '/{(?<=).+?(?=)}/', replacement: '([a-zA-Z0-9]*)', subject: $route);
|
$regex = preg_replace(pattern: '/{.+?}/', replacement: '([a-zA-Z0-9]*)', subject: $route);
|
||||||
$regex = '/^' . str_replace(search: "/", replace: '\\/', subject: $regex) . '$/i';
|
$regex = '/^' . str_replace(search: "/", replace: '\\/', subject: $regex) . '$/i';
|
||||||
|
|
||||||
$route = new Route(name: $name, route: $route, regEx: $regex, parameters: $parameters, callback: $callback);
|
$route = new Route(name: $name, route: $route, regEx: $regex, parameters: $parameters, callback: $callback);
|
||||||
|
|
Loading…
Reference in New Issue