Skip to content

Commit cd49732

Browse files
committed
update
1 parent 1e02cfb commit cd49732

File tree

3 files changed

+23
-29
lines changed

3 files changed

+23
-29
lines changed

composer.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui.include.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8202,7 +8202,7 @@ class SimpleRouter implements Router
82028202

82038203
public function __construct(string $basePath, Responder $responder, Cache $cache, int $ttl)
82048204
{
8205-
$this->basePath = rtrim($basePath, '/');
8205+
$this->basePath = rtrim($basePath, '/') ?: rtrim($this->detectBasePath(), '/');;
82068206
$this->responder = $responder;
82078207
$this->cache = $cache;
82088208
$this->ttl = $ttl;
@@ -8212,18 +8212,18 @@ public function __construct(string $basePath, Responder $responder, Cache $cache
82128212
$this->middlewares = array();
82138213
}
82148214

8215-
private function detectBasePath(ServerRequestInterface $request): string
8215+
private function detectBasePath(): string
82168216
{
8217-
$serverParams = $request->getServerParams();
8218-
if (isset($serverParams['REQUEST_URI'])) {
8219-
$fullPath = urldecode(explode('?', $serverParams['REQUEST_URI'])[0]);
8220-
if (isset($serverParams['PATH_INFO'])) {
8221-
$path = $serverParams['PATH_INFO'];
8217+
if (isset($_SERVER['REQUEST_URI'])) {
8218+
$fullPath = urldecode(explode('?', $_SERVER['REQUEST_URI'])[0]);
8219+
if (isset($_SERVER['PATH_INFO'])) {
8220+
$path = $_SERVER['PATH_INFO'];
82228221
if (substr($fullPath, -1 * strlen($path)) == $path) {
82238222
return substr($fullPath, 0, -1 * strlen($path));
82248223
}
82258224
}
8226-
if ('/' . basename(__FILE__) == $fullPath) {
8225+
$path = '/' . basename(__FILE__);
8226+
if (substr($fullPath, -1 * strlen($path)) == $path) {
82278227
return $fullPath;
82288228
}
82298229
}
@@ -8264,9 +8264,6 @@ public function load(Middleware $middleware) /*: void*/
82648264

82658265
public function route(ServerRequestInterface $request): ResponseInterface
82668266
{
8267-
if (!$this->basePath) {
8268-
$this->basePath = rtrim($this->detectBasePath($request), '/');
8269-
}
82708267
if ($this->registration) {
82718268
$data = gzcompress(json_encode($this->routes, JSON_UNESCAPED_UNICODE));
82728269
$this->cache->set('PathTree', $data, $this->ttl);

ui.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8202,7 +8202,7 @@ class SimpleRouter implements Router
82028202

82038203
public function __construct(string $basePath, Responder $responder, Cache $cache, int $ttl)
82048204
{
8205-
$this->basePath = rtrim($basePath, '/');
8205+
$this->basePath = rtrim($basePath, '/') ?: rtrim($this->detectBasePath(), '/');;
82068206
$this->responder = $responder;
82078207
$this->cache = $cache;
82088208
$this->ttl = $ttl;
@@ -8212,18 +8212,18 @@ public function __construct(string $basePath, Responder $responder, Cache $cache
82128212
$this->middlewares = array();
82138213
}
82148214

8215-
private function detectBasePath(ServerRequestInterface $request): string
8215+
private function detectBasePath(): string
82168216
{
8217-
$serverParams = $request->getServerParams();
8218-
if (isset($serverParams['REQUEST_URI'])) {
8219-
$fullPath = urldecode(explode('?', $serverParams['REQUEST_URI'])[0]);
8220-
if (isset($serverParams['PATH_INFO'])) {
8221-
$path = $serverParams['PATH_INFO'];
8217+
if (isset($_SERVER['REQUEST_URI'])) {
8218+
$fullPath = urldecode(explode('?', $_SERVER['REQUEST_URI'])[0]);
8219+
if (isset($_SERVER['PATH_INFO'])) {
8220+
$path = $_SERVER['PATH_INFO'];
82228221
if (substr($fullPath, -1 * strlen($path)) == $path) {
82238222
return substr($fullPath, 0, -1 * strlen($path));
82248223
}
82258224
}
8226-
if ('/' . basename(__FILE__) == $fullPath) {
8225+
$path = '/' . basename(__FILE__);
8226+
if (substr($fullPath, -1 * strlen($path)) == $path) {
82278227
return $fullPath;
82288228
}
82298229
}
@@ -8264,9 +8264,6 @@ public function load(Middleware $middleware) /*: void*/
82648264

82658265
public function route(ServerRequestInterface $request): ResponseInterface
82668266
{
8267-
if (!$this->basePath) {
8268-
$this->basePath = rtrim($this->detectBasePath($request), '/');
8269-
}
82708267
if ($this->registration) {
82718268
$data = gzcompress(json_encode($this->routes, JSON_UNESCAPED_UNICODE));
82728269
$this->cache->set('PathTree', $data, $this->ttl);

0 commit comments

Comments
 (0)