You are here

function _link_clean_relative in Link 7

Cleaner of relatives urls.

Parameters

string $url: The url to clean up the relative protocol.

1 call to _link_clean_relative()
link_validate_url in ./link.module
Validates a URL.

File

./link.module, line 1658
Defines simple link field types.

Code

function _link_clean_relative($url) {
  $check = substr($url, 0, 2);
  if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
    $protocol = 'https://';
  }
  else {
    $protocol = 'http://';
  }
  if ($check == '//') {
    $url = str_replace('//', $protocol, $url);
  }
  return $url;
}