function Request::preparePathInfo
Prepares the path info.
1 call to Request::preparePathInfo()
- Request::getPathInfo in vendor/
symfony/ http-foundation/ Request.php - Returns the path being requested relative to the executed script.
File
-
vendor/
symfony/ http-foundation/ Request.php, line 1880
Class
- Request
- Request represents an HTTP request.
Namespace
Symfony\Component\HttpFoundationCode
protected function preparePathInfo() : string {
if (null === ($requestUri = $this->getRequestUri())) {
return '/';
}
// Remove the query string from REQUEST_URI
if (false !== ($pos = strpos($requestUri, '?'))) {
$requestUri = substr($requestUri, 0, $pos);
}
if ('' !== $requestUri && '/' !== $requestUri[0]) {
$requestUri = '/' . $requestUri;
}
if (null === ($baseUrl = $this->getBaseUrlReal())) {
return $requestUri;
}
$pathInfo = substr($requestUri, \strlen($baseUrl));
if ('' === $pathInfo) {
// If substr() returns false then PATH_INFO is set to an empty string
return '/';
}
return $pathInfo;
}