1 backdrop_web_test_case.php protected BackdropWebTestCase::getAbsoluteUrl($path)

Takes a path and returns an absolute path.

Parameters

$path: A path from the internal browser content.

Return value

The $path with $base_url prepended, if necessary.:

File

core/modules/simpletest/backdrop_web_test_case.php, line 3010

Class

BackdropWebTestCase
Test case for typical Backdrop tests.

Code

protected function getAbsoluteUrl($path) {
  global $base_url, $base_path;

  $parts = parse_url($path);
  if (empty($parts['host'])) {
    // Ensure that we have a string (and no xpath object).
    $path = (string) $path;
    // Strip $base_path, if existent.
    $length = strlen($base_path);
    if (substr($path, 0, $length) === $base_path) {
      $path = substr($path, $length);
    }
    // Ensure that we have an absolute path.
    if (strlen($path) && $path[0] !== '/') {
      $path = '/' . $path;
    }
    // Finally, prepend the $base_url.
    $path = $base_url . $path;
  }
  return $path;
}