fix regex to support for non english letters

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
});
This commit is contained in:
mrjk990 2021-01-09 23:20:29 +02:00 committed by GitHub
parent 6168bc9ab5
commit c2cd96ab90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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