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

View File

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