From db78135d19b8fd0e5c0f0b1cc6ecb9f5e5cffe06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sessing=C3=B8?= Date: Wed, 16 Mar 2016 19:57:54 +0100 Subject: [PATCH] [BUGFIX] Only render group if prefix matches. --- src/Pecee/SimpleRouter/RouterBase.php | 8 +------- src/Pecee/SimpleRouter/RouterGroup.php | 7 ++++++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Pecee/SimpleRouter/RouterBase.php b/src/Pecee/SimpleRouter/RouterBase.php index 5fdd7aa..5439178 100644 --- a/src/Pecee/SimpleRouter/RouterBase.php +++ b/src/Pecee/SimpleRouter/RouterBase.php @@ -86,7 +86,7 @@ class RouterBase { $this->currentRoute = $route; - if($route instanceof RouterGroup && is_callable($route->getCallback())) { + if($route instanceof RouterGroup && $route->matchRoute($this->request) && is_callable($route->getCallback())) { $group = $route; $route->renderRoute($this->request); $mergedSettings = array_merge($route->getMergeableSettings(), $settings); @@ -126,12 +126,6 @@ class RouterBase { $route = $this->controllerUrlMap[$i]; - if($route->getGroup() !== null) { - if($route->getGroup()->matchDomain($this->request) === false) { - continue; - } - } - $routeMatch = $route->matchRoute($this->request); if($routeMatch) { diff --git a/src/Pecee/SimpleRouter/RouterGroup.php b/src/Pecee/SimpleRouter/RouterGroup.php index a44c91f..739bf81 100644 --- a/src/Pecee/SimpleRouter/RouterGroup.php +++ b/src/Pecee/SimpleRouter/RouterGroup.php @@ -66,7 +66,12 @@ class RouterGroup extends RouterEntry { } public function matchRoute(Request $request) { - return null; + // Skip if prefix doesn't match + if($this->getPrefix() !== null && stripos($request->getUri(), $this->getPrefix()) === false) { + return false; + } + + return $this->matchDomain($request); } public function setExceptionHandler($class) {