route.php : Add support of URL matching with or without Slash
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2020 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -21,6 +21,8 @@ class route
|
||||
public $debug=0;
|
||||
//public $defaultOutput = "html"; // Default renderer : html
|
||||
|
||||
/** Allow slashes in the url when matching the regex */
|
||||
public $allowSlashes = true;
|
||||
// Provide the the class catch errors in routing.
|
||||
// Must be provided in an array(class,method);
|
||||
public $errors = null;
|
||||
@@ -316,8 +318,12 @@ class route
|
||||
//$regex = str_replace ("?", "\?", $regex);
|
||||
//$regex = str_replace (".", "\.", $regex);
|
||||
$regex = str_replace ("{", "(?P<", $regex);
|
||||
$regex = str_replace ("}", ">.+)", $regex);
|
||||
if ($this->allowSlashes)
|
||||
$regex = str_replace ("}", ">.+)", $regex);
|
||||
else
|
||||
$regex = str_replace ("}", ">[^/]+)", $regex);
|
||||
unset ($matches);
|
||||
//echo "REGEX=".htmlentities ($regex)." ? URL=".htmlentities ($url);
|
||||
$rcRegex = preg_match ($regex, $url, $matches);
|
||||
if ($rcRegex !== FALSE && $rcRegex !== 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user