diff --git a/route.php b/route.php index 9667100..618a17e 100644 --- a/route.php +++ b/route.php @@ -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) {