Skip to content

Commit cec0e77

Browse files
committed
Version 0.5.9
- Improved performance if no "regex route" is defined - Fixed check not unseted routes
1 parent 66c07b1 commit cec0e77

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/Inphinit/App.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
class App
1717
{
1818
/** Inphinit framework version */
19-
const VERSION = '0.5.8';
19+
const VERSION = '0.5.9';
2020

2121
private static $events = array();
2222
private static $configs = array();

src/Inphinit/Routing/Route.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static function set($method, $path, $action)
4949
/**
5050
* Get action controller from current route
5151
*
52-
* @return array|bool
52+
* @return array|int
5353
*/
5454
public static function get()
5555
{
@@ -58,7 +58,6 @@ public static function get()
5858
}
5959

6060
$args = array();
61-
6261
$routes = &parent::$httpRoutes;
6362
$path = \UtilsPath();
6463
$method = $_SERVER['REQUEST_METHOD'];
@@ -78,7 +77,7 @@ public static function get()
7877
$resp = $verbs[$method];
7978
} elseif (isset($verbs['ANY'])) {
8079
$resp = $verbs['ANY'];
81-
} elseif (isset($verbs)) {
80+
} elseif (isset($verbs) && array_filter($verbs)) {
8281
return self::$current = 405;
8382
} else {
8483
return self::$current = 404;

src/Inphinit/Routing/Router.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@ abstract class Router
4444
*/
4545
protected static function find($route, $path, array &$matches)
4646
{
47-
$re = Regex::parse($route);
47+
if (strpos($route, '{:') !== false) {
48+
$re = Regex::parse($route);
4849

49-
if ($re !== false && preg_match('#^' . $re . '$#', $path, $matches)) {
50-
array_shift($matches);
51-
return true;
50+
if ($re !== false && preg_match('#^' . $re . '$#', $path, $matches)) {
51+
array_shift($matches);
52+
return true;
53+
}
5254
}
5355

5456
return false;

0 commit comments

Comments
 (0)