protected function WebAssert::cleanUrl in Drupal 8
Same name and namespace in other branches
- 9 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);
}