Generating a URL with query string parameters that are numeric results in duplicated items in the query string.
Add the following code to a THEMENAME_preprocess_node()
function:
$query['foo'][] = 'bar';
$query['foo'][] = 'baz';
$url = Url::fromUri('https://google.com', ['query' => $query]);
$variables['test'] = [
'#type' => 'link',
'#title' => 'foo',
] + $url->toRenderArray();
And the following to your theme's node.html.twig
file:
Test link is {{ test }}.
The result is:
https://google.com/?foo[0]=bar&foo[1]=baz&foo[2]=bar&foo[3]=baz