Skip to content

Commit 3d45851

Browse files
committed
Merge pull request #72 from skipperbent/development
[BUGFIX] Only render group if prefix matches.
2 parents ee5c220 + db78135 commit 3d45851

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/Pecee/SimpleRouter/RouterBase.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ protected function processRoutes(array $routes, array $settings = array(), array
8686

8787
$this->currentRoute = $route;
8888

89-
if($route instanceof RouterGroup && is_callable($route->getCallback())) {
89+
if($route instanceof RouterGroup && $route->matchRoute($this->request) && is_callable($route->getCallback())) {
9090
$group = $route;
9191
$route->renderRoute($this->request);
9292
$mergedSettings = array_merge($route->getMergeableSettings(), $settings);
@@ -126,12 +126,6 @@ public function routeRequest() {
126126

127127
$route = $this->controllerUrlMap[$i];
128128

129-
if($route->getGroup() !== null) {
130-
if($route->getGroup()->matchDomain($this->request) === false) {
131-
continue;
132-
}
133-
}
134-
135129
$routeMatch = $route->matchRoute($this->request);
136130

137131
if($routeMatch) {

src/Pecee/SimpleRouter/RouterGroup.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ public function renderRoute(Request $request) {
6666
}
6767

6868
public function matchRoute(Request $request) {
69-
return null;
69+
// Skip if prefix doesn't match
70+
if($this->getPrefix() !== null && stripos($request->getUri(), $this->getPrefix()) === false) {
71+
return false;
72+
}
73+
74+
return $this->matchDomain($request);
7075
}
7176

7277
public function setExceptionHandler($class) {

0 commit comments

Comments
 (0)