Skip to content

Commit 969b646

Browse files
committed
Merge pull request #18 from skipperbent/development
[OPTIMISATION] Optimised router handling - router will now use the or…
2 parents af730e6 + c2cf233 commit 969b646

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

src/Pecee/SimpleRouter/RouterBase.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,6 @@ public function routeRequest() {
100100
// Loop through each route-request
101101
$this->processRoutes($this->routes);
102102

103-
// Make sure the urls is in the right order when comparing
104-
usort($this->controllerUrlMap, function($a, $b) {
105-
if(stripos($b->getUrl(), '{') !== false) {
106-
return $a->getUrl();
107-
}
108-
return strcmp($b->getUrl(), $a->getUrl());
109-
});
110-
111103
$routeNotAllowed = false;
112104

113105
/* @var $route RouterEntry */

src/Pecee/SimpleRouter/RouterRoute.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function matchRoute(Request $request) {
4949
// Check if url parameter count matches
5050
if(stripos($url, $routeMatch) === 0) {
5151

52-
$matches = true;
52+
$matches = (count(explode('/', rtrim($url, '/'))) == count(explode('/', rtrim($route, '/'))));
5353

5454
if($this->regexMatch) {
5555
$parameters = $this->parseParameters($url, true, $this->regexMatch);
@@ -62,7 +62,7 @@ public function matchRoute(Request $request) {
6262
} else {
6363

6464
$url = explode('/', $url);
65-
$route = explode('/', $route);
65+
$route = explode('/', rtrim($route, '/'));
6666

6767
$parameters = array();
6868

0 commit comments

Comments
 (0)