Url: Do not throw ProgrammingError if there is no relative url available

refs #5600
This commit is contained in:
Johannes Meyer 2015-09-24 14:03:15 +02:00
parent 338c0680e0
commit 165dc00fad
1 changed files with 4 additions and 8 deletions

View File

@ -282,19 +282,15 @@ class Url
* Return the relative url
*
* @return string
*
* @throws ProgrammingError In case no relative url path is set or it is absolute
*/
public function getRelativeUrl($separator = '&')
{
$path = $this->getPath();
if (! $path) {
throw new ProgrammingError('Unable to provide a relative URL. No path set');
} elseif ($path[0] === '/') {
throw new ProgrammingError('Cannot provide a relative URL. Path is absolute');
$path = $this->buildPathQueryAndFragment($separator);
if ($path && $path[0] === '/') {
return '';
}
return $this->buildPathQueryAndFragment($separator);
return $path;
}
/**