You are here

function _feeds_tamper_join_url in Feeds Tamper 6

Same name and namespace in other branches
  1. 7 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 115

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 .= '@';
    }
    if (preg_match('/!^[\\da-f]*:[\\da-f.:]+$!ui/', $parts['host'])) {
      $url .= '[' . $parts['host'] . ']';

      // IPv6
    }
    else {
      $url .= $parts['host'];
    }

    // IPv4 or name
    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;
}