slight clean-up to uri method.

This commit is contained in:
Taylor Otwell 2011-11-11 22:50:41 -06:00
parent 6cbac0e064
commit f9ec36d7f8
1 changed files with 5 additions and 5 deletions

View File

@ -40,7 +40,7 @@ public static function uri()
// Remove the root application URL from the request URI. If the application // Remove the root application URL from the request URI. If the application
// is nested within a sub-directory of the web document root, this will get // is nested within a sub-directory of the web document root, this will get
// rid of the sub-directories from the request URI. // rid of all of the the sub-directories from the request URI.
$base = parse_url(Config::$items['application']['url'], PHP_URL_PATH); $base = parse_url(Config::$items['application']['url'], PHP_URL_PATH);
if (strpos($uri, $base) === 0) if (strpos($uri, $base) === 0)
@ -48,8 +48,6 @@ public static function uri()
$uri = substr($uri, strlen($base)); $uri = substr($uri, strlen($base));
} }
// Remove the application index file. It is not used for anything as far
// as the framework and routing is concerned, so it's worthless.
$index = '/'.Config::$items['application']['index']; $index = '/'.Config::$items['application']['index'];
if ($index !== '/' and strpos($uri, $index) === 0) if ($index !== '/' and strpos($uri, $index) === 0)
@ -57,10 +55,12 @@ public static function uri()
$uri = substr($uri, strlen($index)); $uri = substr($uri, strlen($index));
} }
$uri = trim($uri, '/');
// Format the final request URI. If there is nothing left, we will just // Format the final request URI. If there is nothing left, we will just
// return a single forward slash. Otherwise, we'll remove all of the // return a single forward slash. Otherwise, we'll remove all of the
// leading and trailing spaces from the URI. // leading and trailing spaces from the URI before returning it.
return static::$uri = (($uri = trim($uri, '/')) !== '') ? $uri : '/'; return static::$uri = ($uri !== '') ? $uri : '/';
} }
/** /**