You are here

function advagg_glue_url in Advanced CSS/JS Aggregation 7.2

Alt to http_build_url().

Parameters

array $parsed: Array from parse_url().

bool $strip_query_and_fragment: If set to TRUE the query and fragment will be removed from the output.

Return value

string URI is returned.

See also

http://php.net/parse-url#85963

7 calls to advagg_glue_url()
advagg_add_dns_prefetch in ./advagg.module
Add in the dns-prefetch header for CSS and JS external files.
advagg_file_create_url in ./advagg.module
Wrapper around file_create_url() to do post-processing on the created url.
advagg_install_check_via_http in ./advagg.install
Make sure http requests to css/js files work correctly.
advagg_install_url_mod in ./advagg.install
Modify $url and $options before making the HTTP request.
advagg_load_css_stylesheet in ./advagg.inc
Loads the stylesheet and resolves all @import commands.

... See full list

File

./advagg.module, line 5475
Advanced CSS/JS aggregation module.

Code

function advagg_glue_url(array $parsed, $strip_query_and_fragment = FALSE) {
  $uri = '';
  if (isset($parsed['scheme'])) {
    switch (strtolower($parsed['scheme'])) {

      // Mailto uri.
      case 'mailto':
        $uri .= $parsed['scheme'] . ':';
        break;

      // Protocol relative uri.
      case '//':
        $uri .= $parsed['scheme'];
        break;

      // Standard uri.
      default:
        $uri .= $parsed['scheme'] . '://';
    }
  }
  $uri .= isset($parsed['user']) ? $parsed['user'] . (isset($parsed['pass']) ? ':' . $parsed['pass'] : '') . '@' : '';
  $uri .= isset($parsed['host']) ? $parsed['host'] : '';
  $uri .= !empty($parsed['port']) ? ':' . $parsed['port'] : '';
  if (isset($parsed['path'])) {
    $uri .= substr($parsed['path'], 0, 1) === '/' ? $parsed['path'] : (!empty($uri) ? '/' : '') . $parsed['path'];
  }
  if (!$strip_query_and_fragment) {
    $uri .= isset($parsed['query']) ? '?' . $parsed['query'] : '';
    $uri .= isset($parsed['fragment']) ? '#' . $parsed['fragment'] : '';
  }
  return $uri;
}