File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed
lib/Gitlab/HttpClient/Message
test/Gitlab/Tests/HttpClient/Message Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ final class QueryStringBuilder
15
15
public static function build ($ query )
16
16
{
17
17
if (!is_array ($ query )) {
18
- return rawurlencode ($ query );
18
+ return static :: rawurlencode ($ query );
19
19
}
20
20
return implode ('& ' , array_map (function ($ value , $ key ) {
21
21
return static ::encode ($ value , $ key );
@@ -32,7 +32,7 @@ public static function build($query)
32
32
private static function encode ($ query , $ prefix )
33
33
{
34
34
if (!is_array ($ query )) {
35
- return rawurlencode ($ prefix ).'= ' .rawurlencode ($ query );
35
+ return static :: rawurlencode ($ prefix ).'= ' .static :: rawurlencode ($ query );
36
36
}
37
37
38
38
$ isIndexedArray = static ::isIndexedArray ($ query );
@@ -57,4 +57,20 @@ public static function isIndexedArray(array $query)
57
57
58
58
return array_keys ($ query ) === range (0 , count ($ query ) - 1 );
59
59
}
60
+
61
+ /**
62
+ * Encode a value like rawurlencode, but return "0" when false is given.
63
+ *
64
+ * @param mixed $value
65
+ *
66
+ * @return string
67
+ */
68
+ private static function rawurlencode ($ value )
69
+ {
70
+ if ($ value === false ) {
71
+ return '0 ' ;
72
+ }
73
+
74
+ return rawurlencode ($ value );
75
+ }
60
76
}
Original file line number Diff line number Diff line change @@ -40,6 +40,12 @@ public function queryStringProvider()
40
40
'iids%5B0%5D=88&iids%5B2%5D=86 '
41
41
];
42
42
43
+ //Boolean encoding
44
+ yield [
45
+ ['push_events ' => false , 'merge_requests_events ' => 1 ],
46
+ 'push_events=0&merge_requests_events=1 '
47
+ ];
48
+
43
49
//A deeply nested array.
44
50
yield [
45
51
[
You can’t perform that action at this time.
0 commit comments