public function getPathInfo($referrer = null)
{
$baseUrl = $this->prepareBaseUrl($referrer);
if (null === $referrer) {
return '/';
}
$pathInfo = '/';
// Remove the query string from REQUEST_URI
if ($pos = strpos($referrer, '?')) {
$referrer = substr($referrer, 0, $pos);
}
$host = $this->request->getHost();
if (null !== $baseUrl && false === ($pathInfo = substr($referrer, strlen($baseUrl)))) {
// If substr() returns false then PATH_INFO is set to an empty string
return '/';
} elseif (null === $baseUrl) {
return $referrer;
} elseif ($pos = strpos($pathInfo, $host)) {
$pathInfo = substr($pathInfo, $pos + strlen($host));
}
return (string) $pathInfo;
}