Fix processing the basePath, array mismatch issue with tokenize
This commit is contained in:
parent
241d652283
commit
bf6da3b990
|
@ -162,9 +162,8 @@ class Router
|
||||||
* @param string $uri
|
* @param string $uri
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private static function tokenize(string $uri)
|
private static function tokenize(string $uri, array $constraints)
|
||||||
{
|
{
|
||||||
$constraints = self::$routes[$uri]['constraints'];
|
|
||||||
$constraintKeys = array_keys($constraints);
|
$constraintKeys = array_keys($constraints);
|
||||||
|
|
||||||
preg_match_all('/(?:{([\w\-]+)})+/', $uri, $matches);
|
preg_match_all('/(?:{([\w\-]+)})+/', $uri, $matches);
|
||||||
|
@ -208,11 +207,11 @@ class Router
|
||||||
foreach (self::$routes as $route) {
|
foreach (self::$routes as $route) {
|
||||||
// If the basePath isn't just "root"
|
// If the basePath isn't just "root"
|
||||||
if ($basePath != '/') {
|
if ($basePath != '/') {
|
||||||
$route['route'] = $basePath.$route['route'];
|
$route['route'] = self::trimRoute($basePath.$route['route']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare route by tokenizing.
|
// Prepare route by tokenizing.
|
||||||
$tokenized = '#^'.self::tokenize($route['route']).'$#u';
|
$tokenized = '#^'.self::tokenize($route['route'], $route['constraints']).'$#u';
|
||||||
|
|
||||||
// If the tokenized route matches the current path...
|
// If the tokenized route matches the current path...
|
||||||
if (preg_match($tokenized, $path, $matches)) {
|
if (preg_match($tokenized, $path, $matches)) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user