Development

- Fixed global regex match not working properly.
- Feature: added option to change regular expression used for parameters on routes.
- Added unit-tests for custom parameter regular expression.
- Updated documentation to reflect new features.
This commit is contained in:
Simon Sessingø
2017-05-09 06:43:26 +02:00
parent 8901e7c125
commit 9dd80dd1d9
6 changed files with 133 additions and 34 deletions
+8 -3
View File
@@ -1,4 +1,5 @@
<?php
namespace Pecee\SimpleRouter\Route;
use Pecee\Http\Request;
@@ -18,17 +19,21 @@ class RouteUrl extends LoadableRoute
/* Match global regular-expression for route */
$regexMatch = $this->matchRegex($request, $url);
if ($regexMatch === false) {
return false;
}
/* Make regular expression based on route */
/* Parse parameters from current route */
$parameters = $this->parseParameters($this->url, $url);
if ($parameters === null) {
/* If no custom regular expression or parameters was found on this route, we stop */
if ($regexMatch === null && $parameters === null) {
return false;
}
$this->setParameters($parameters);
/* Set the parameters */
$this->setParameters((array)$parameters);
return true;
}