Skip to content

Commit 955ba2e

Browse files
committed
Fix getRequestTarget error
close swlib/saber#129
1 parent e97d9d0 commit 955ba2e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/Request.php

+13-2
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,20 @@ public function getRequestTarget(): string
4141
return $this->requestTarget;
4242
}
4343

44-
parse_str($this->uri->getQuery(), $query);
44+
$query = [];
45+
if (!empty($this->uri->getQuery())) {
46+
// Fix foo.bar
47+
foreach(preg_split('/&(?!amp;)/', $this->uri->getQuery()) as $param) {
48+
$item = explode('=', $param);
49+
$query[$item[0]] = $item[1] ?? '';
50+
}
51+
}
4552
$query = $this->getQueryParams() + $query; //attribute value first
46-
$query = http_build_query($query);
53+
$query = urldecode(http_build_query($query));
54+
// Fix redundant =
55+
if (substr($this->uri->getQuery(), -1) !== '=') {
56+
$query = substr($query, 0, -1);
57+
}
4758

4859
$target = $this->uri->getPath() ?: '/';
4960
$target = empty($query) ? $target : $target . '?' . $query;

0 commit comments

Comments
 (0)