From 9df9a5df04d359bef8e8dc812659f0faea5d441e Mon Sep 17 00:00:00 2001 From: Mohammad Sadeghi Date: Mon, 24 Sep 2012 16:15:11 +0330 Subject: [PATCH 1/3] segment pattern to match a single segment, also matches UTF-8 segments. --- laravel/routing/router.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/laravel/routing/router.php b/laravel/routing/router.php index e9935e4c..b0e751f1 100644 --- a/laravel/routing/router.php +++ b/laravel/routing/router.php @@ -76,6 +76,7 @@ class Router { public static $patterns = array( '(:num)' => '([0-9]+)', '(:any)' => '([a-zA-Z0-9\.\-_%=]+)', + '(:segment)' => '([^/]+)', '(:all)' => '(.*)', ); @@ -87,6 +88,7 @@ class Router { public static $optional = array( '/(:num?)' => '(?:/([0-9]+)', '/(:any?)' => '(?:/([a-zA-Z0-9\.\-_%=]+)', + '/(:segment?)' => '(?:/([^/]+)', '/(:all?)' => '(?:/(.*)', ); From 7647c3fcba5aaa11566d4b50a83c32f737feb714 Mon Sep 17 00:00:00 2001 From: Mohammad Sadeghi Date: Mon, 24 Sep 2012 16:39:28 +0330 Subject: [PATCH 2/3] added 'u' flag for preg_match to match UTF-8 URIs. --- laravel/routing/router.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/laravel/routing/router.php b/laravel/routing/router.php index b0e751f1..86c04a16 100644 --- a/laravel/routing/router.php +++ b/laravel/routing/router.php @@ -76,7 +76,6 @@ class Router { public static $patterns = array( '(:num)' => '([0-9]+)', '(:any)' => '([a-zA-Z0-9\.\-_%=]+)', - '(:segment)' => '([^/]+)', '(:all)' => '(.*)', ); @@ -88,7 +87,6 @@ class Router { public static $optional = array( '/(:num?)' => '(?:/([0-9]+)', '/(:any?)' => '(?:/([a-zA-Z0-9\.\-_%=]+)', - '/(:segment?)' => '(?:/([^/]+)', '/(:all?)' => '(?:/(.*)', ); @@ -496,7 +494,7 @@ protected static function match($method, $uri) // we just did before we started searching. if (str_contains($route, '(')) { - $pattern = '#^'.static::wildcards($route).'$#'; + $pattern = '#^'.static::wildcards($route).'$#u'; // If we get a match we'll return the route and slice off the first // parameter match, as preg_match sets the first array item to the From 9d28938d5589bbe02a956625f318d852085122c5 Mon Sep 17 00:00:00 2001 From: Mohammad Sadeghi Date: Mon, 24 Sep 2012 16:42:09 +0330 Subject: [PATCH 3/3] . --- laravel/routing/router.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/laravel/routing/router.php b/laravel/routing/router.php index 86c04a16..b2578169 100644 --- a/laravel/routing/router.php +++ b/laravel/routing/router.php @@ -76,6 +76,7 @@ class Router { public static $patterns = array( '(:num)' => '([0-9]+)', '(:any)' => '([a-zA-Z0-9\.\-_%=]+)', + '(:segment)' => '([^/]+)', '(:all)' => '(.*)', ); @@ -87,6 +88,7 @@ class Router { public static $optional = array( '/(:num?)' => '(?:/([0-9]+)', '/(:any?)' => '(?:/([a-zA-Z0-9\.\-_%=]+)', + '/(:segment?)' => '(?:/([^/]+)', '/(:all?)' => '(?:/(.*)', );