Skip to content

Commit 4ddb74f

Browse files
committed
Version 0.5.10 👾
- Improved performance in `UtilsPath()` - Improved performance in `Group::checkDomain()` method
1 parent cec0e77 commit 4ddb74f

File tree

3 files changed

+11
-17
lines changed

3 files changed

+11
-17
lines changed

src/Experimental/Routing/Group.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,9 @@ protected function checkDomain()
177177
if (self::$cachehost !== null) {
178178
$host = self::$cachehost;
179179
} else {
180-
$fhost = Request::header('Host');
181-
$host = strstr($fhost, ':', true);
182-
$host = $host ? $host : $fhost;
180+
$host = Request::header('Host');
183181

184-
self::$cachehost = $host;
182+
self::$cachehost = $host ? strtok($host, ':') : '';
185183
}
186184

187185
if ($host === $this->domain) {

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.9';
19+
const VERSION = '0.5.10';
2020

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

src/Utils.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,14 @@ function UtilsPath()
9494
static $pathinfo;
9595

9696
if ($pathinfo === null) {
97-
$requri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
98-
$sname = $_SERVER['SCRIPT_NAME'];
99-
100-
if ($requri !== $sname && $sname !== '/index.php') {
101-
$pathinfo = rtrim(strtr(dirname($sname), '\\', '/'), '/');
102-
$pathinfo = substr(urldecode($requri), strlen($pathinfo));
103-
104-
if ($pathinfo === false) {
105-
$pathinfo = '/';
106-
}
107-
} else {
108-
$pathinfo = urldecode($requri);
97+
$requri = urldecode(strtok($_SERVER['REQUEST_URI'], '?'));
98+
$sname = dirname($_SERVER['SCRIPT_NAME']);
99+
100+
if ($sname === '\\' || $sname === '/') {
101+
$pathinfo = $requri;
102+
} elseif ($requri !== $sname) {
103+
$pathinfo = rtrim($sname, '/');
104+
$pathinfo = substr($requri, strlen($pathinfo));
109105
}
110106
}
111107

0 commit comments

Comments
 (0)