You are here

function _js_http_build_url in JS Callback Handler 7.2

Alt to http_build_url().

Parameters

array $parsed: Array from parse_url().

Return value

string URI is returned.

1 call to _js_http_build_url()
js_process_autocomplete in ./js.module
Autocomplete #process callback.

File

./js.module, line 424
JavaScript callback handler module.

Code

function _js_http_build_url(array $parsed) {
  $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'];
  }
  $uri .= isset($parsed['query']) ? '?' . $parsed['query'] : '';
  $uri .= isset($parsed['fragment']) ? '#' . $parsed['fragment'] : '';
  return $uri;
}