Loading core/modules/block/tests/src/Functional/BlockUiTest.php +1 −3 Original line number Diff line number Diff line Loading @@ -343,9 +343,7 @@ public function testBlockPlacementIndicator(): void { // Removing a block will remove the block placement indicator. $this->clickLink('Remove'); $this->submitForm([], 'Remove'); // @todo https://www.drupal.org/project/drupal/issues/2980527 this should be // 'admin/structure/block/list/stark' but there is a bug. $this->assertSession()->addressEquals('admin/structure/block'); $this->assertSession()->addressEquals('admin/structure/block/list/stark'); } /** Loading core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php +32 −24 Original line number Diff line number Diff line Loading @@ -152,6 +152,11 @@ public function processOutbound($path, &$options = [], ?Request $request = NULL, elseif ($config['source'] == LanguageNegotiationUrl::CONFIG_DOMAIN) { if (is_object($options['language']) && !empty($config['domains'][$options['language']->getId()])) { // Check if the base URLs match, return early if they do. if (isset($options['base_url']) && $request && $request->getHost() === parse_url($options['base_url'], PHP_URL_HOST)) { return $path; } // Save the original base URL. If it contains a port, we need to // retain it below. if (!empty($options['base_url'])) { Loading @@ -159,7 +164,9 @@ public function processOutbound($path, &$options = [], ?Request $request = NULL, $normalized_base_url = str_replace(['https://', 'http://'], '', $options['base_url']); } // Ask for an absolute URL with our modified base URL. // Ask for an absolute URL with our modified base URL only if the domain // is different from the current request domain. if ($request && $request->getHost() !== $config['domains'][$options['language']->getId()]) { $options['absolute'] = TRUE; $options['base_url'] = $url_scheme . '://' . $config['domains'][$options['language']->getId()]; Loading Loading @@ -189,6 +196,7 @@ public function processOutbound($path, &$options = [], ?Request $request = NULL, } } } } return $path; } Loading core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php +45 −0 Original line number Diff line number Diff line Loading @@ -322,6 +322,51 @@ public static function providerTestDomain() { return $domain_configuration; } /** * Tests path outbound processing correctly setting relative/absolute paths. */ public function testProcessOutboundOutputsRelativePathsForSameDomain(): void { $this->languageManager->expects($this->any()) ->method('getCurrentLanguage') ->willReturn($this->languages['en']); $config = $this->getConfigFactoryStub([ 'language.negotiation' => [ 'url' => [ 'source' => LanguageNegotiationUrl::CONFIG_DOMAIN, 'domains' => [ 'de' => 'example.de', 'en' => 'example.com', ], ], ], ]); $request = Request::create('', 'GET', [], [], [], ['HTTP_HOST' => 'example.com']); $method = new LanguageNegotiationUrl(); $method->setLanguageManager($this->languageManager); $method->setConfig($config); $method->setCurrentUser($this->user); // Check relative paths are used when the language // is the current language. $options = [ 'language' => $this->languages['en'], ]; $method->processOutbound('foo', $options, $request); // $options['absolute'] not set or null equals to FALSE. $this->assertFalse($options['absolute'] ?? FALSE); // Check absolute paths are used when the language // is not the current language. $options = [ 'language' => $this->languages['de'], ]; $method->processOutbound('foo', $options, $request); $this->assertTrue($options['absolute']); } } // @todo Remove as part of https://www.drupal.org/node/2481833. Loading Loading
core/modules/block/tests/src/Functional/BlockUiTest.php +1 −3 Original line number Diff line number Diff line Loading @@ -343,9 +343,7 @@ public function testBlockPlacementIndicator(): void { // Removing a block will remove the block placement indicator. $this->clickLink('Remove'); $this->submitForm([], 'Remove'); // @todo https://www.drupal.org/project/drupal/issues/2980527 this should be // 'admin/structure/block/list/stark' but there is a bug. $this->assertSession()->addressEquals('admin/structure/block'); $this->assertSession()->addressEquals('admin/structure/block/list/stark'); } /** Loading
core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php +32 −24 Original line number Diff line number Diff line Loading @@ -152,6 +152,11 @@ public function processOutbound($path, &$options = [], ?Request $request = NULL, elseif ($config['source'] == LanguageNegotiationUrl::CONFIG_DOMAIN) { if (is_object($options['language']) && !empty($config['domains'][$options['language']->getId()])) { // Check if the base URLs match, return early if they do. if (isset($options['base_url']) && $request && $request->getHost() === parse_url($options['base_url'], PHP_URL_HOST)) { return $path; } // Save the original base URL. If it contains a port, we need to // retain it below. if (!empty($options['base_url'])) { Loading @@ -159,7 +164,9 @@ public function processOutbound($path, &$options = [], ?Request $request = NULL, $normalized_base_url = str_replace(['https://', 'http://'], '', $options['base_url']); } // Ask for an absolute URL with our modified base URL. // Ask for an absolute URL with our modified base URL only if the domain // is different from the current request domain. if ($request && $request->getHost() !== $config['domains'][$options['language']->getId()]) { $options['absolute'] = TRUE; $options['base_url'] = $url_scheme . '://' . $config['domains'][$options['language']->getId()]; Loading Loading @@ -189,6 +196,7 @@ public function processOutbound($path, &$options = [], ?Request $request = NULL, } } } } return $path; } Loading
core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php +45 −0 Original line number Diff line number Diff line Loading @@ -322,6 +322,51 @@ public static function providerTestDomain() { return $domain_configuration; } /** * Tests path outbound processing correctly setting relative/absolute paths. */ public function testProcessOutboundOutputsRelativePathsForSameDomain(): void { $this->languageManager->expects($this->any()) ->method('getCurrentLanguage') ->willReturn($this->languages['en']); $config = $this->getConfigFactoryStub([ 'language.negotiation' => [ 'url' => [ 'source' => LanguageNegotiationUrl::CONFIG_DOMAIN, 'domains' => [ 'de' => 'example.de', 'en' => 'example.com', ], ], ], ]); $request = Request::create('', 'GET', [], [], [], ['HTTP_HOST' => 'example.com']); $method = new LanguageNegotiationUrl(); $method->setLanguageManager($this->languageManager); $method->setConfig($config); $method->setCurrentUser($this->user); // Check relative paths are used when the language // is the current language. $options = [ 'language' => $this->languages['en'], ]; $method->processOutbound('foo', $options, $request); // $options['absolute'] not set or null equals to FALSE. $this->assertFalse($options['absolute'] ?? FALSE); // Check absolute paths are used when the language // is not the current language. $options = [ 'language' => $this->languages['de'], ]; $method->processOutbound('foo', $options, $request); $this->assertTrue($options['absolute']); } } // @todo Remove as part of https://www.drupal.org/node/2481833. Loading