Skip to content

Commit

Permalink
Sort routes when scopes are connected.
Browse files Browse the repository at this point in the history
This solves errors/performance issues when Router::url() is called
before Router::parse().
  • Loading branch information
markstory committed Jun 29, 2014
1 parent 7ce2f45 commit 982b696
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,6 @@ public static function parse($url) {
$url = '/' . $url;
}

krsort(static::$_pathScopes);
foreach (static::$_pathScopes as $path => $collection) {
if (strpos($url, $path) === 0) {
return $collection->parse($url);
Expand Down Expand Up @@ -1094,6 +1093,7 @@ public static function scope($path, $params = [], $callback = null) {

if (empty(static::$_pathScopes[$path])) {
static::$_pathScopes[$path] = $collection;
krsort(static::$_pathScopes);
} else {
static::$_pathScopes[$path]->merge($collection);
}
Expand Down

0 comments on commit 982b696

Please sign in to comment.