From bf6da3b9900589eda2f8ff4b7c534e7435ee9f9b Mon Sep 17 00:00:00 2001 From: Sky Johnson Date: Sun, 19 Dec 2021 13:20:21 -0600 Subject: [PATCH] Fix processing the basePath, array mismatch issue with tokenize --- src/Router.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Router.php b/src/Router.php index 46eaa3d..fb4fe73 100644 --- a/src/Router.php +++ b/src/Router.php @@ -162,9 +162,8 @@ class Router * @param string $uri * @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); preg_match_all('/(?:{([\w\-]+)})+/', $uri, $matches); @@ -208,11 +207,11 @@ class Router foreach (self::$routes as $route) { // If the basePath isn't just "root" if ($basePath != '/') { - $route['route'] = $basePath.$route['route']; + $route['route'] = self::trimRoute($basePath.$route['route']); } // 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 (preg_match($tokenized, $path, $matches)) {