Fix auto add '/' if URL path is not absolute (now only if host set)

master 1.2.1
Julien Rosset 3 years ago
parent 47f1fd4d02
commit 64924af14e

@ -123,7 +123,7 @@ class UrlInfo {
$url .= ':' . $this->getPort();
}
if ($this->hasPath()) {
$url .= ($url === '' || !$this->isPathAbsolute() ? '' : '/') . $this->getPath();
$url .= ($this->hasHost() && !$this->isPathAbsolute() ? '/' : '') . $this->getPath();
}
if ($this->hasArguments()) {
$url .= '?' . $this->getArgumentsAsString();
@ -304,7 +304,7 @@ class UrlInfo {
* @return string|null The URL path
*/
public function getPath (): ?string {
return $this->hasPathParts() ? $this->getPathParts()->join('/') : null;
return $this->hasPathParts() ? preg_replace('#/{2,}#', '/', $this->getPathParts()->join('/')) : null;
}
/**
* The URL path parts

Loading…
Cancel
Save