Issue #3027763 by quietone, LiamPower, pratik_kamble: UnroutedUrlAssembler removes query params array item key in buildExternalUrl()

merge-requests/2/head
catch 2020-06-30 09:50:26 +01:00
parent bf94a9e49a
commit 60c1f976cb
3 changed files with 7 additions and 1 deletions

View File

@ -77,7 +77,7 @@ class UnroutedUrlAssembler implements UnroutedUrlAssemblerInterface {
$parsed += ['query' => []];
$options += ['query' => []];
$options['query'] = NestedArray::mergeDeep($parsed['query'], $options['query']);
$options['query'] = NestedArray::mergeDeepArray([$parsed['query'], $options['query']], TRUE);
if ($parsed['fragment'] && !$options['fragment']) {
$options['fragment'] = '#' . $parsed['fragment'];

View File

@ -313,6 +313,11 @@ class UrlTest extends BrowserTestBase {
$result = Url::fromUri($url)->toString();
$this->assertEqual($url, $result);
// Verify external URL can contain a query string with an integer key.
$url = $test_url . '?120=1';
$result = Url::fromUri($url)->toString();
$this->assertEqual($url, $result);
// Verify external URL can be extended with a query string.
$url = $test_url;
$query = ['awesome' => 'drupal'];

View File

@ -99,6 +99,7 @@ class UnroutedUrlAssemblerTest extends UnitTestCase {
'override-query' => ['https://example.com/test?foo=1#bar', ['query' => ['foo' => 2]], 'https://example.com/test?foo=2#bar'],
'override-query-merge' => ['https://example.com/test?foo=1#bar', ['query' => ['bar' => 2]], 'https://example.com/test?foo=1&bar=2#bar'],
'override-deep-query-merge' => ['https://example.com/test?foo=1#bar', ['query' => ['bar' => ['baz' => 'foo']]], 'https://example.com/test?foo=1&bar%5Bbaz%5D=foo#bar'],
'override-deep-query-merge-int-ket' => ['https://example.com/test?120=1', ['query' => ['bar' => ['baz' => 'foo']]], 'https://example.com/test?120=1&bar%5Bbaz%5D=foo'],
'override-fragment' => ['https://example.com/test?foo=1#bar', ['fragment' => 'baz'], 'https://example.com/test?foo=1#baz'],
['//www.drupal.org', [], '//www.drupal.org'],
];