You are here

function _w3c_validator_get_path_from_url in W3C Validator 7

Returns internal path, query and fragment from external URL.

Parameters

string $url:

string $normal_path:

Return value

array An associative array containing the keys:

  • 'path': the internal relatif path
  • 'query': An array of query parameters of $url, if existent.
  • 'fragment': The fragment of $url, if existent.

- language : the language

1 call to _w3c_validator_get_path_from_url()
_w3c_validator_save_result in ./w3c_validator.module
Save a validation result in the database.

File

./w3c_validator.module, line 395

Code

function _w3c_validator_get_path_from_url($url, $normal_path = TRUE) {
  global $base_path;

  // Get hostname
  preg_match("/^(https?:\\/\\/)?([^\\/]+)/i", $url, $domain);

  // Format localhost + base_path (http://hostname/drupalbase)
  $base = (isset($domain[0]) ? $domain[0] : '') . $base_path;

  // If $url contains $base, remove the $base part
  if (strpos($url, $base) === 0) {
    $path = str_replace($base, '', $url);
  }
  else {
    $path = $url;
  }

  // Parse the path (without $base)
  $result = drupal_parse_url($path);

  // Get normal path
  if ($normal_path) {
    $result['path'] = drupal_get_normal_path($result['path']);
  }
  return $result;
}