From 6c6f92a7c98fcaa05ed7cef4bdd5600c4bfc3613 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 13 Jul 2011 11:03:22 -0700 Subject: [PATCH 1/2] Added default value to URL::to_asset method. --- system/url.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/url.php b/system/url.php index 3e1de338..76a615d3 100644 --- a/system/url.php +++ b/system/url.php @@ -50,7 +50,7 @@ public static function to_secure($url = '') * @param string $url * @return string */ - public static function to_asset($url) + public static function to_asset($url = '') { return static::to($url, false, true); } From 03044c7d4c61161d8e22d82ec4be84fb57a2a549 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 13 Jul 2011 13:13:18 -0700 Subject: [PATCH 2/2] Refactoring router. --- system/router.php | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/system/router.php b/system/router.php index 86715ece..baaf5ee2 100644 --- a/system/router.php +++ b/system/router.php @@ -41,7 +41,9 @@ public static function route($method, $uri) { foreach (explode(', ', $keys) as $key) { - if (preg_match('#^'.$key = static::translate_wildcards($key).'$#', $uri)) + $key = str_replace(':num', '[0-9]+', str_replace(':any', '[a-zA-Z0-9\-_]+', $key)); + + if (preg_match('#^'.$key.'$#', $uri)) { return Request::$route = new Route($keys, $callback, static::parameters($uri, $key)); } @@ -76,17 +78,6 @@ private static function load_from_directory($uri) return (file_exists($path = APP_PATH.'routes/'.$segments[0].EXT)) ? require $path : array(); } - /** - * Translate route URI wildcards to regular expressions. - * - * @param string $key - * @return string - */ - private static function translate_wildcards($key) - { - return str_replace(':num', '[0-9]+', str_replace(':any', '[a-zA-Z0-9\-_]+', $key)); - } - /** * Extract the parameters from a URI based on a route URI. *