function UrlHelperTest::providerTestIsExternal
Same name in other branches
- 9 core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php \Drupal\Tests\Component\Utility\UrlHelperTest::providerTestIsExternal()
- 8.9.x core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php \Drupal\Tests\Component\Utility\UrlHelperTest::providerTestIsExternal()
- 10 core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php \Drupal\Tests\Component\Utility\UrlHelperTest::providerTestIsExternal()
Provides data for self::testIsExternal().
Return value
array
File
-
core/
tests/ Drupal/ Tests/ Component/ Utility/ UrlHelperTest.php, line 431
Class
- UrlHelperTest
- @group Utility
Namespace
Drupal\Tests\Component\UtilityCode
public static function providerTestIsExternal() {
return [
[
'/internal/path',
FALSE,
],
[
'https://example.com/external/path',
TRUE,
],
[
'javascript://fake-external-path',
FALSE,
],
// External URL without an explicit protocol.
[
'//www.example.com/foo/bar?foo=bar&bar=baz&baz#foo',
TRUE,
],
// Internal URL starting with a slash.
[
'/www.example.com',
FALSE,
],
// Simple external URLs.
[
'http://example.com',
TRUE,
],
[
'https://example.com',
TRUE,
],
[
'http://example.com/foo/bar?foo=bar&bar=baz&baz#foo',
TRUE,
],
[
'//example.com',
TRUE,
],
// Some browsers ignore or strip leading control characters.
[
"\x00//www.example.com",
TRUE,
],
[
"\x08//www.example.com",
TRUE,
],
[
"\x1f//www.example.com",
TRUE,
],
[
"\n//www.example.com",
TRUE,
],
// JSON supports decoding directly from UTF-8 code points.
[
json_decode('"\\u00AD"') . "//www.example.com",
TRUE,
],
[
json_decode('"\\u200E"') . "//www.example.com",
TRUE,
],
[
json_decode('"\\uE0020"') . "//www.example.com",
TRUE,
],
[
json_decode('"\\uE000"') . "//www.example.com",
TRUE,
],
// Backslashes should be normalized to forward.
[
'\\\\example.com',
TRUE,
],
// Local URLs.
[
'node',
FALSE,
],
[
'/system/ajax',
FALSE,
],
[
'?q=foo:bar',
FALSE,
],
[
'node/edit:me',
FALSE,
],
[
'/example.com',
FALSE,
],
[
'<front>',
FALSE,
],
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.