From c2cd96ab90d74dbf81fdc643b67054809463478f Mon Sep 17 00:00:00 2001 From: mrjk990 Date: Sat, 9 Jan 2021 23:20:29 +0200 Subject: [PATCH] fix regex to support for non english letters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix regex to support for non english letters like arabic example: // http://domain.com/dance/الرقص-العربي Route::add( '/([\d\w\._]+)/([\p{L}\d\-]+)', function($cat, $slug) { // do something }); --- src/Steampixel/Route.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Steampixel/Route.php b/src/Steampixel/Route.php index 48760d5..bc94adc 100644 --- a/src/Steampixel/Route.php +++ b/src/Steampixel/Route.php @@ -57,7 +57,9 @@ class Route { } } } - + + $path = urldecode($path); + // Get current request method $method = $_SERVER['REQUEST_METHOD']; @@ -81,7 +83,7 @@ class Route { $route['expression'] = $route['expression'].'$'; // Check path match - if (preg_match('#'.$route['expression'].'#'.($case_matters ? '' : 'i'), $path, $matches)) { + if (preg_match('#'.$route['expression'].'#'.($case_matters ? '' : 'iu'), $path, $matches)) { $path_match_found = true; // Cast allowed method to array if it's not one already, then run through all methods