Skip to content

Commit 56a2585

Browse files
committed
fix request target for URLs with empty path
1 parent 029bf7e commit 56a2585

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Psr7/Message/Request.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,16 @@ public function getRequestTarget(): string
3232
return $this->requestTarget;
3333
}
3434

35-
$this->requestTarget = $this->uri->getPath();
35+
$target = $this->uri->getPath();
36+
if ($target === "") {
37+
$target = "/";
38+
}
39+
3640
if ($this->uri->getQuery()) {
37-
$this->requestTarget .= '?' . $this->uri->getQuery();
41+
$target .= '?' . $this->uri->getQuery();
3842
}
3943

40-
return $this->requestTarget;
44+
return $target;
4145
}
4246

4347
/**

0 commit comments

Comments
 (0)