function WebAssert::cleanUrl
Same name in other branches
- 9 core/tests/Drupal/Tests/WebAssert.php \Drupal\Tests\WebAssert::cleanUrl()
- 10 core/tests/Drupal/Tests/WebAssert.php \Drupal\Tests\WebAssert::cleanUrl()
- 11.x core/tests/Drupal/Tests/WebAssert.php \Drupal\Tests\WebAssert::cleanUrl()
File
-
core/
tests/ Drupal/ Tests/ WebAssert.php, line 42
Class
- WebAssert
- Defines a class with methods for asserting presence of elements during tests.
Namespace
Drupal\TestsCode
protected function cleanUrl($url) {
if ($url instanceof Url) {
$url = $url->setAbsolute()
->toString();
}
// Strip the base URL from the beginning for absolute URLs.
if ($this->baseUrl !== '' && strpos($url, $this->baseUrl) === 0) {
$url = substr($url, strlen($this->baseUrl));
}
// Make sure there is a forward slash at the beginning of relative URLs for
// consistency.
if (parse_url($url, PHP_URL_HOST) === NULL && strpos($url, '/') !== 0) {
$url = "/{$url}";
}
return parent::cleanUrl($url);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.