diff --git a/core/lib/Drupal/Core/Url.php b/core/lib/Drupal/Core/Url.php index 7add013..5d9b3da 100644 --- a/core/lib/Drupal/Core/Url.php +++ b/core/lib/Drupal/Core/Url.php @@ -298,7 +298,7 @@ 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. + // Support for scheme-relative URLs. if (empty($uri_parts['scheme']) && strpos($uri, '//') === 0) { $uri_parts['scheme'] = 'relative'; } diff --git a/core/modules/menu_ui/src/Tests/MenuTest.php b/core/modules/menu_ui/src/Tests/MenuTest.php index e826a05..b99d66a 100644 --- a/core/modules/menu_ui/src/Tests/MenuTest.php +++ b/core/modules/menu_ui/src/Tests/MenuTest.php @@ -588,10 +588,10 @@ public function testMenuSchemeRelative() { // Make a path with query and fragment on. $path = '//drupal.org'; - $item = $this->addMenuLink(0, $path); + $item = $this->addMenuLink('', $path); - $this->drupalGet('admin/structure/menu/item/' . $item['mlid'] . '/edit'); - $this->assertFieldByName('link_path', $path, 'Path is found with scheme-relative URL.'); + $this->drupalGet('admin/structure/menu/item/' . $item->id() . '/edit'); + $this->assertFieldByName('link[0][uri]', $path, 'Path is found with scheme-relative URL.'); } /** diff --git a/core/modules/system/src/Tests/Common/UrlTest.php b/core/modules/system/src/Tests/Common/UrlTest.php index 2676b8b..fcfab0a 100644 --- a/core/modules/system/src/Tests/Common/UrlTest.php +++ b/core/modules/system/src/Tests/Common/UrlTest.php @@ -285,30 +285,30 @@ public function testSchemeRelativeUrls() { // Verify scheme-relative URL can contain a fragment. $url = $test_url . '#drupal'; - $result = \Drupal::url($url); + $result = Url::fromUri($url)->toString(); $this->assertEqual($url, $result, 'Scheme-relative URL with fragment works without a fragment in $options.'); // Verify fragment can be overidden in an external URL. $url = $test_url . '#drupal'; $fragment = $this->randomMachineName(10); - $result = \Drupal::url($url, array('fragment' => $fragment)); + $result = Url::fromUri($url, ['fragment' => $fragment])->toString(); $this->assertEqual($test_url . '#' . $fragment, $result, 'Scheme-relative URL fragment is overidden with a custom fragment in $options.'); // Verify external URL can contain a query string. $url = $test_url . '?drupal=awesome'; - $result = \Drupal::url($url); + $result = Url::fromUri($url)->toString(); $this->assertEqual($url, $result, 'Scheme-relative URL with query string works without a query string in $options.'); // Verify external URL can be extended with a query string. $url = $test_url; - $query = array($this->randomMachineName(5) => $this->randomMachineName(5)); - $result = \Drupal::url($url, array('query' => $query)); + $query = [$this->randomMachineName(5) => $this->randomMachineName(5)]; + $result = Url::fromUri($url, ['query' => $query])->toString(); $this->assertEqual($url . '?' . http_build_query($query, '', '&'), $result, 'Scheme-relative URL can be extended with a query string in $options.'); // Verify query string can be extended in an external URL. $url = $test_url . '?drupal=awesome'; - $query = array($this->randomMachineName(5) => $this->randomMachineName(5)); - $result = \Drupal::url($url, array('query' => $query)); + $query = [$this->randomMachineName(5) => $this->randomMachineName(5)]; + $result = Url::fromUri($url, ['query' => $query])->toString(); $this->assertEqual($url . '&' . http_build_query($query, '', '&'), $result, 'Scheme-relative URL query string can be extended with a custom query string in $options.'); } diff --git a/core/tests/Drupal/Tests/Core/UnroutedUrlTest.php b/core/tests/Drupal/Tests/Core/UnroutedUrlTest.php index 6013810..04f3f5a 100644 --- a/core/tests/Drupal/Tests/Core/UnroutedUrlTest.php +++ b/core/tests/Drupal/Tests/Core/UnroutedUrlTest.php @@ -108,7 +108,7 @@ public function providerFromUri() { * @expectedException \InvalidArgumentException */ public function testFromInvalidUri($uri) { - $url = Url::fromUri($uri); + Url::fromUri($uri); } /** @@ -119,7 +119,6 @@ public function providerFromInvalidUri() { // Schemeless paths. ['test'], ['/test'], - ['//test'], // Schemeless path with a query string. ['foo?bar'], // Only a query string.