[BUGFIX] Bugfixes

This commit is contained in:
Simon Sessingø
2015-10-07 00:14:59 +02:00
parent 02a874d01c
commit 2ff88f9ed4
5 changed files with 140 additions and 73 deletions
+16 -1
View File
@@ -11,7 +11,22 @@ class RouterGroup extends RouterEntry {
public function matchRoute($requestMethod, $url) {
// Check if request method is allowed
if(count($this->method) === 0 || strtolower($this->method) == strtolower($requestMethod) || is_array($this->method) && in_array($this->method, self::$allowedRequestTypes)) {
if(strtolower($url) == strtolower($this->prefix) || stripos($url, $this->prefix) === 0) {
$hasAccess = (!$this->method);
if($this->method) {
if(is_array($this->method)) {
$hasAccess = (in_array($requestMethod, $this->method));
} else {
$hasAccess = strtolower($this->method) == strtolower($requestMethod);
}
}
if(!$hasAccess) {
throw new RouterException('Method not allowed');
}
return $this;
}