You are here

function _feeds_tamper_join_url in Feeds Tamper 7

Same name and namespace in other branches
  1. 6 plugins/absolute_url.inc \_feeds_tamper_join_url()
1 call to _feeds_tamper_join_url()
_feeds_tamper_absolute_url in plugins/absolute_url.inc

File

plugins/absolute_url.inc, line 117

Code

function _feeds_tamper_join_url($parts) {
  $url = '';
  if (!empty($parts['scheme'])) {
    $url .= $parts['scheme'] . ':';
  }
  if (isset($parts['host'])) {
    $url .= '//';
    if (isset($parts['user'])) {
      $url .= $parts['user'];
      if (isset($parts['pass'])) {
        $url .= ':' . $parts['pass'];
      }
      $url .= '@';
    }

    // IPv6.
    if (preg_match('/^[\\da-f]*:[\\da-f.:]+$/ui', $parts['host'])) {
      $url .= '[' . $parts['host'] . ']';
    }
    else {

      // IPv4 or name.
      $url .= $parts['host'];
    }
    if (isset($parts['port'])) {
      $url .= ':' . $parts['port'];
    }
    if (!empty($parts['path']) && $parts['path'][0] != '/') {
      $url .= '/';
    }
  }
  if (!empty($parts['path'])) {
    $url .= $parts['path'];
  }
  if (isset($parts['query'])) {
    $url .= '?' . $parts['query'];
  }
  if (isset($parts['fragment'])) {
    $url .= '#' . $parts['fragment'];
  }
  return $url;
}