tweaking router formatting.

This commit is contained in:
Taylor Otwell 2011-07-29 22:56:18 -05:00
parent f16f90c89c
commit 5b2858824b
1 changed files with 5 additions and 4 deletions

View File

@ -26,8 +26,8 @@ class Router {
*/
public function __construct($method, $uri, $routes = null)
{
// Put the request method and URI in route form.
// Routes begin with the request method and a forward slash.
// Put the request method and URI in route form. Routes begin with
// the request method and a forward slash.
$this->request = $method.' /'.trim($uri, '/');
$this->routes = (is_array($routes)) ? $routes : $this->load($uri);
@ -113,8 +113,9 @@ private function translate_wildcards($key)
{
$replacements = 0;
// For optional parameters, first translate the wildcards to their regex equivalent, sans the ")?" ending.
// We will add the endings back on after we know how many replacements we made.
// For optional parameters, first translate the wildcards to their
// regex equivalent, sans the ")?" ending. We will add the endings
// back on after we know how many replacements we made.
$key = str_replace(array('/(:num?)', '/(:any?)'), array('(?:/([0-9]+)', '(?:/([a-zA-Z0-9\-_]+)'), $key, $replacements);
$key .= ($replacements > 0) ? str_repeat(')?', $replacements) : '';