Development

Changeset 7514

You must first sign up to be able to contribute.

Changeset 7514

Show
Ignore:
Timestamp:
02/16/08 11:39:00 (1 year ago)
Author:
fabien
Message:

fixed trailing slash problem in routing + made some minor tweaks

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/routing/sfPatternRouting.class.php

    r7457 r7514  
    253253    $suffix = $this->defaultSuffix; 
    254254 
    255     // used for performance reasons 
    256     $namesHash = array(); 
    257  
    258     $r = null; 
    259     if (($route == '') || ($route == '/')) 
    260     { 
    261       $regexp = '/^[\/]*$/'; 
    262       $this->routes[$name] = array($route, $regexp, array(), array(), $default, $requirements, $suffix); 
     255    // a route must start by a slash. If there is none, add it automatically 
     256    if ('/' != $route[0]) 
     257    { 
     258      $route = '/'.$route;  
     259    } 
     260 
     261    if ($route == '/') 
     262    { 
     263      $this->routes[$name] = array($route, '/^[\/]*$/', array(), array(), $default, $requirements, $suffix); 
    263264    } 
    264265    else 
    265266    { 
     267      // used for performance reasons 
     268      $namesHash = array(); 
     269      $r = null; 
    266270      $elements = array(); 
    267271      foreach (explode('/', $route) as $element) 
     
    458462      } 
    459463      $realUrl = preg_replace('/\/\*(\/|$)/', "$tmp$1", $realUrl); 
    460     } 
    461  
    462     // strip off last divider character 
    463     if (strlen($realUrl) > 1) 
    464     { 
    465       $realUrl = rtrim($realUrl, $divider); 
    466     } 
    467  
    468     if ($realUrl != '/'
     464 
     465      // strip off last divider character 
     466      if (strlen($realUrl) > 1) 
     467      { 
     468        $realUrl = rtrim($realUrl, $divider); 
     469      } 
     470    } 
     471 
     472    if ('/' != $realUrl && '/' != substr($realUrl, -1)
    469473    { 
    470474      $realUrl .= $suffix; 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting, and supporting several large Open-Source projects.