File tree Expand file tree Collapse file tree 1 file changed +25
-5
lines changed Expand file tree Collapse file tree 1 file changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -420,12 +420,32 @@ use \GuzzleHttp\Exception\GuzzleException;
420
420
*/
421
421
protected function buildQuery(array $params): string
422
422
{
423
- // Let http_build_query do the heavy lifting:
424
- $qs = http_build_query($params , ' ' , ' &' , PHP_QUERY_RFC3986);
423
+ $sanitizedParams = $params ;
425
424
426
- // Normalize numeric indices to empty brackets: % 5B0% 5D= → % 5B% 5D=
427
- // (i.e., environment% 5B0% 5D=env1 → environment% 5B% 5D=env1)
428
- return preg_replace(' /%5B\d +%5D=/' , ' %5B%5D=' , $qs );
425
+ foreach ($sanitizedParams as &$value ) {
426
+ if (is_array($value )) {
427
+ array_walk_recursive($value , function (&$item ) {
428
+ if (null === $item ) {
429
+ $item = ' ' ;
430
+ }
431
+ });
432
+ }
433
+ }
434
+ unset($value);
435
+
436
+ $qs = http_build_query($sanitizedParams, '', '& ', PHP_QUERY_RFC3986);
437
+
438
+ if ('' === $qs || false === strpos($qs, '%5B')) {
439
+ return $qs ;
440
+ }
441
+
442
+ $parts = explode('& ', $qs);
443
+
444
+ foreach ($parts as $index => $part) {
445
+ $parts [$index ] = preg_replace(' /([^%5B]+)%5B\d +%5D/' , ' $1%5B%5D' , $part , 1);
446
+ }
447
+
448
+ return implode('& ', $parts);
429
449
}
430
450
431
451
/**
You can’t perform that action at this time.
0 commit comments