Skip to content

Commit d836360

Browse files
committed
better basePath support
1 parent 84c7dc1 commit d836360

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/Tqdev/PhpCrudApi/Middleware/Router/SimpleRouter.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,13 @@ private function detectBasePath(string $basePath): string
4141
if ($basePath) {
4242
return $basePath;
4343
}
44-
if (isset($_SERVER['PATH_INFO'])) {
45-
$fullPath = explode('?', $_SERVER['REQUEST_URI'])[0];
46-
$path = $_SERVER['PATH_INFO'];
47-
if (substr($fullPath, -1 * strlen($path)) == $path) {
48-
return substr($fullPath, 0, -1 * strlen($path));
49-
}
44+
$fullPath = explode('?', $_SERVER['REQUEST_URI'])[0];
45+
$path = $_SERVER['PATH_INFO'];
46+
if (!$path) {
47+
return $fullPath;
48+
}
49+
if (substr($fullPath, -1 * strlen($path)) == $path) {
50+
return substr($fullPath, 0, -1 * strlen($path));
5051
}
5152
return $_SERVER['PHP_SELF'];
5253
}

0 commit comments

Comments
 (0)