diff --git a/core/lib/Drupal/Core/Url.php b/core/lib/Drupal/Core/Url.php index c6a5f05..7add013 100644 --- a/core/lib/Drupal/Core/Url.php +++ b/core/lib/Drupal/Core/Url.php @@ -298,6 +298,10 @@ public static function fromUri($uri, $options = []) { if ($uri_parts === FALSE) { throw new \InvalidArgumentException(SafeMarkup::format('The URI "@uri" is malformed.', ['@uri' => $uri])); } + // Support for protocol-relative URLs. + if (empty($uri_parts['scheme']) && strpos($uri, '//') === 0) { + $uri_parts['scheme'] = 'relative'; + } if (empty($uri_parts['scheme'])) { throw new \InvalidArgumentException(SafeMarkup::format('The URI "@uri" is invalid. You must use a valid URI scheme.', ['@uri' => $uri])); }