mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 00:37:52 +00:00
Development
- Fixed: namespace being prepended on `RouterController` routes with absolute namespaces. - Fixed: match domain on `RouteController` and `RouteResource`. - Fixed: strict url-matching on `RouteController`. Fix should provide better url-matching. - Fixed: `RouterResource` always matching first url when having simular urls (ex: `/funny-cat` and `/funny-dog`). - Added `loadRoutes` method to `Router` class so routes now can be loaded without routing the request (useful when running in Cli etc). - Removed `getInstance` from `Router` class. Please use `SimpleRouter::router()` for singleton usage instead. - Added `getRemoteAddr` alias-method for `getIp` in `Request` class. - Added `getValue` to `IInputItem` interface. - Other minor optimizations. - Updated documentation with note on absolute/relative namespaces.
This commit is contained in:
@@ -89,28 +89,26 @@ class RouteController extends LoadableRoute implements IControllerRoute
|
||||
$url = rtrim($url, '/') . '/';
|
||||
|
||||
/* Match global regular-expression for route */
|
||||
if ($this->matchRegex($request, $url) === true) {
|
||||
return true;
|
||||
$regexMatch = $this->matchRegex($request, $url);
|
||||
|
||||
if ($regexMatch === false || stripos($url, $this->url) !== 0 || strtolower($url) !== strtolower($this->url)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (stripos($url, $this->url) === 0 && strtolower($url) === strtolower($this->url)) {
|
||||
$strippedUrl = trim(str_ireplace($this->url, '/', $url), '/');
|
||||
$path = explode('/', $strippedUrl);
|
||||
|
||||
$strippedUrl = trim(str_ireplace($this->url, '/', $url), '/');
|
||||
if (count($path) > 0) {
|
||||
|
||||
$path = explode('/', $strippedUrl);
|
||||
$method = (isset($path[0]) === false || trim($path[0]) === '') ? $this->defaultMethod : $path[0];
|
||||
$this->method = $request->getMethod() . ucfirst($method);
|
||||
|
||||
if (count($path) > 0) {
|
||||
$this->parameters = array_slice($path, 1);
|
||||
|
||||
$method = (!isset($path[0]) || trim($path[0]) === '') ? $this->defaultMethod : $path[0];
|
||||
$this->method = $method;
|
||||
// Set callback
|
||||
$this->setCallback($this->controller . '@' . $this->method);
|
||||
|
||||
$this->parameters = array_slice($path, 1);
|
||||
|
||||
// Set callback
|
||||
$this->setCallback($this->controller . '@' . $this->method);
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user