You are here

private static function Redirects::parseCompleteUrl in Hook Update Deploy Tools 8

Same name and namespace in other branches
  1. 7 src/Redirects.php \HookUpdateDeployTools\Redirects::parseCompleteUrl()

Parses the url and creates some variations needed for redirects.

Parameters

string $url: The url to be parsed (by reference)

Return value

array The url fully parsed.

1 call to Redirects::parseCompleteUrl()
Redirects::parseList in src/Redirects.php
Create redirects from a list of redirects.

File

src/Redirects.php, line 350

Class

Redirects
Public methods for importing redirects.

Namespace

HookUpdateDeployTools

Code

private static function parseCompleteUrl(&$url) {
  self::fixBadFragment($url);
  $parsed_url = parse_url($url);
  self::fixMissingScheme($url, $parsed_url);

  // Trim left and right  slashes and empty spaces from path.
  $parsed_url['path'] = !empty($parsed_url['path']) ? trim($parsed_url['path']) : '';
  $parsed_url['path'] = !empty($parsed_url['path']) ? trim($parsed_url['path'], '/') : '';

  // Assemble fullURI which lacks query and fragment.
  $parsed_url['fullURI'] = !empty($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
  $parsed_url['fullURI'] .= !empty($parsed_url['host']) ? $parsed_url['host'] . '/' : '';
  $parsed_url['fullURI'] .= !empty($parsed_url['path']) ? $parsed_url['path'] : '';

  // Assemble completeURL which includes query and fragment.
  $parsed_url['completeURL'] = $parsed_url['fullURI'];
  $parsed_url['completeURL'] .= !empty($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
  $parsed_url['completeURL'] .= !empty($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
  return $parsed_url;
}