diff -u b/core/lib/Drupal/Core/Routing/UrlGenerator.php b/core/lib/Drupal/Core/Routing/UrlGenerator.php --- b/core/lib/Drupal/Core/Routing/UrlGenerator.php +++ b/core/lib/Drupal/Core/Routing/UrlGenerator.php @@ -170,8 +170,6 @@ $path = $this->getInternalPathFromRoute($route, $parameters); $path = $this->processPath($path, $options); - $absolute = !empty($options['absolute']); - if (!empty($options['prefix'])) { $path = ltrim($path, '/'); $prefix = empty($path) ? rtrim($options['prefix'], '/') : $options['prefix']; @@ -185,8 +183,27 @@ } } - $base_url = isset($options['base_url']) ? $options['base_url'] : $this->context->getBaseUrl(); - if (!$absolute || preg_match('/^http(s)?\:\\/\//', $base_url) === 1 || !$host = $this->context->getHost()) { + // The base_url might be rewritten from the language rewrite in domain mode. + if (isset($options['base_url'])) { + $base_url = $options['base_url']; + + if (isset($options['https']) && $this->mixedModeSessions) { + if ($options['https'] === TRUE) { + $base_url = str_replace('http://', 'https://', $base_url); + } + elseif ($options['https'] === FALSE) { + $base_url = str_replace('https://', 'http://', $base_url); + } + } + + return $base_url . $path . $fragment; + } + else { + $base_url = $this->context->getBaseUrl(); + } + + $absolute = !empty($options['absolute']); + if (!$absolute || !$host = $this->context->getHost()) { return $base_url . $path . $fragment; } diff -u b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php --- b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php @@ -266,6 +266,15 @@ $url = $this->generator->generateFromRoute('test_1', array(), $options); $this->assertEquals('http://www.example.com:8888/hello/world', $url); + $options = array('base_url' => 'http://www.example.com:8888', 'https' => TRUE); + // Mixed-mode sessions are not enabled, so the https option is ignored. + $url = $this->generator->generateFromRoute('test_1', array(), $options); + $this->assertEquals('http://www.example.com:8888/hello/world', $url); + + // Mixed-mode sessions are enabled, so the https option is obeyed. + $url = $this->generatorMixedMode->generateFromRoute('test_1', array(), $options); + $this->assertEquals('https://www.example.com:8888/hello/world', $url); + $this->routeProcessorManager->expects($this->once()) ->method('processOutbound') ->with($this->anything());