Loading core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php +4 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,10 @@ public function assemble($uri, array $options = [], $collect_bubbleable_metadata * {@inheritdoc} */ protected function buildExternalUrl($uri, array $options = [], $collect_bubbleable_metadata = FALSE) { // Early return so external URLs are not altered unnecessarily. if (empty($options['query']) && empty($options['fragment']) && !isset($options['https'])) { return $collect_bubbleable_metadata ? (new GeneratedUrl())->setGeneratedUrl($uri) : $uri; } $this->addOptionDefaults($options); // Split off the query & fragment. $parsed = UrlHelper::parse($uri); Loading core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php +16 −0 Original line number Diff line number Diff line Loading @@ -195,6 +195,22 @@ public function testAssembleWithStartingSlashEnabledProcessing(): void { $this->assertEquals($expected_generated_url, $result); } /** * Tests external URLs are only processed if necessary. * * @testWith ["http://example.org", "http://example.org"] * ["http://example.org?flag", "http://example.org?flag"] * ["http://example.org?flag=", "http://example.org?flag="] * ["http://example.org?flag=", "http://example.org?flag", {"query": {"flag": ""}}] * ["http://example.org?tag=one&tag=two", "http://example.org?tag=one&tag=two"] * ["http://example.org?tag%5B0%5D=three", "http://example.org?tag=one&tag=two", {"query": {"tag": ["three"]}}] */ public function testAssembleExternalUrls(string $expected, string $uri, array $options = []): void { $this->setupRequestStack(FALSE); $result = $this->unroutedUrlAssembler->assemble($uri, $options); $this->assertEquals($expected, $result); } /** * Setups the request stack for a given subdir. * Loading Loading
core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php +4 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,10 @@ public function assemble($uri, array $options = [], $collect_bubbleable_metadata * {@inheritdoc} */ protected function buildExternalUrl($uri, array $options = [], $collect_bubbleable_metadata = FALSE) { // Early return so external URLs are not altered unnecessarily. if (empty($options['query']) && empty($options['fragment']) && !isset($options['https'])) { return $collect_bubbleable_metadata ? (new GeneratedUrl())->setGeneratedUrl($uri) : $uri; } $this->addOptionDefaults($options); // Split off the query & fragment. $parsed = UrlHelper::parse($uri); Loading
core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php +16 −0 Original line number Diff line number Diff line Loading @@ -195,6 +195,22 @@ public function testAssembleWithStartingSlashEnabledProcessing(): void { $this->assertEquals($expected_generated_url, $result); } /** * Tests external URLs are only processed if necessary. * * @testWith ["http://example.org", "http://example.org"] * ["http://example.org?flag", "http://example.org?flag"] * ["http://example.org?flag=", "http://example.org?flag="] * ["http://example.org?flag=", "http://example.org?flag", {"query": {"flag": ""}}] * ["http://example.org?tag=one&tag=two", "http://example.org?tag=one&tag=two"] * ["http://example.org?tag%5B0%5D=three", "http://example.org?tag=one&tag=two", {"query": {"tag": ["three"]}}] */ public function testAssembleExternalUrls(string $expected, string $uri, array $options = []): void { $this->setupRequestStack(FALSE); $result = $this->unroutedUrlAssembler->assemble($uri, $options); $this->assertEquals($expected, $result); } /** * Setups the request stack for a given subdir. * Loading