@@ -4810,13 +4810,16 @@ private function detectBasePath(string $basePath): string
4810
4810
return $ basePath ;
4811
4811
}
4812
4812
if (isset ($ _SERVER ['PATH_INFO ' ])) {
4813
- $ fullPath = array_shift ( explode ('? ' ,$ _SERVER ['REQUEST_URI ' ])) ;
4813
+ $ fullPath = explode ('? ' , $ _SERVER ['REQUEST_URI ' ])[ 0 ] ;
4814
4814
$ path = $ _SERVER ['PATH_INFO ' ];
4815
- if (substr ($ fullPath , -1 *strlen ($ path )) == $ path ) {
4816
- return substr ($ fullPath , 0 , -1 *strlen ($ path ));
4815
+ if (!$ path ) {
4816
+ return $ _SERVER ['PHP_SELF ' ];
4817
+ }
4818
+ if (substr ($ fullPath , -1 * strlen ($ path )) == $ path ) {
4819
+ return substr ($ fullPath , 0 , -1 * strlen ($ path ));
4817
4820
}
4818
4821
}
4819
- return '' ;
4822
+ return '/ ' ;
4820
4823
}
4821
4824
4822
4825
private function loadPathTree (): PathTree
@@ -4870,15 +4873,10 @@ private function getRouteNumbers(ServerRequestInterface $request): array
4870
4873
4871
4874
private function removeBasePath (ServerRequestInterface $ request ): ServerRequestInterface
4872
4875
{
4873
- if ($ this ->basePath ) {
4874
- $ path = $ request ->getUri ()->getPath ();
4875
- $ basePath = rtrim ($ this ->basePath , '/ ' );
4876
- if (substr ($ path , 0 , strlen ($ basePath )) == $ basePath ) {
4877
- $ path = substr ($ path , strlen ($ basePath ));
4878
- $ request = $ request ->withUri ($ request ->getUri ()->withPath ($ path ));
4879
- }
4880
- } elseif (isset ($ _SERVER ['PATH_INFO ' ])) {
4881
- $ path = $ _SERVER ['PATH_INFO ' ];
4876
+ $ path = $ request ->getUri ()->getPath ();
4877
+ $ basePath = rtrim ($ this ->basePath , '/ ' );
4878
+ if (substr ($ path , 0 , strlen ($ basePath )) == $ basePath ) {
4879
+ $ path = substr ($ path , strlen ($ basePath ));
4882
4880
$ request = $ request ->withUri ($ request ->getUri ()->withPath ($ path ));
4883
4881
}
4884
4882
return $ request ;
0 commit comments