Join a URL with multiple directories
487618
def _join_url_dir(cls, url, *args):
        

        for path in args:
            url = url.rstrip('/') + '/'
            url = urljoin(url, path.lstrip('/'))

        return url
864498
public function joinUrlParts() {
		if (0 === func_num_args()) {
			throw new \InvalidArgumentException('Need at least one argument');
		}

		$parts = func_get_args();
		$trimSlashes = function(&$part) {
			$part = trim($part, '/');
		};
		array_walk($parts, $trimSlashes);

		return implode('/', $parts);
	}
894432
def join_file_uri(scheme, host, path, query)
      str = String.new("#{scheme}://")
      str << host if host
      path = "/#{path}" unless path.start_with?("/".freeze)
      str << URI::Generic::DEFAULT_PARSER.escape(path)
      str << "?#{query}" if query
      str
    end
192594
def url_dirname(url):
    
    p = six.moves.urllib.parse.urlparse(url)
    for e in [private.FILE_EXT_JSON, private.FILE_EXT_YAML]:
        if p.path.endswith(e):
            return six.moves.urllib.parse.urlunparse(
                p[:2]+
                (os.path.dirname(p.path),)+
                p[3:]
            )
    return url
943164
protected List<String> joinUrls(List<String> l) {
    List<String> newList = new ArrayList<>();
    boolean inUrl = false;
    StringBuilder url = new StringBuilder();
    String urlQuote = null;
    for (int i = 0; i < l.size(); i++) {
      if (urlStartsAt(i, l)) {
        inUrl = true;
        if (i-1 >= 0) {
          urlQuote = l.get(i-1);
        }
        url.append(l.get(i));
      } else if (inUrl && urlEndsAt(i, l, urlQuote)) {
        inUrl = false;
        urlQuote = null;
        newList.add(url.toString());
        url.setLength(0);
        newList.add(l.get(i));
      } else if (inUrl) {
        url.append(l.get(i));
      } else {
        newList.add(l.get(i));
      }
    }
    if (url.length() > 0) {
      newList.add(url.toString());
    }
    return newList;
  }
1341668
def make_url(url, *paths):
    
    for path in paths:
        url = re.sub(r'/?$', re.sub(r'^/?', '/', path), url)
    return url
747744
def join_url_parts(*args):
    
    # check for edge case
    if len(args) == 1:
        return args[0]

    return_val = clean_url_segment(args[0])

    for i in range(1, len(args)):
        arg = args[i]

        if i == len(args) - 1:
            # no need to remove a trailing slash if this is the last segment
            return_val += '/' + arg
        else:
            # remove a trailing slash so it won't be duplicated
            return_val += '/' + clean_url_segment(arg)

    return return_val
102986
def pathjoin(*parts, **kvs):
    ''''''
    url = kvs.pop('url', '/')
    url = url + '/' + '/'.join(parts)
    url = normalize_url(url)
    return url
555469
function(url) {
    var dir;
    if (typeof url === "string" && url) {
      dir = url.split("#")[0].split("?")[0];
      dir = url.slice(0, url.lastIndexOf("/") + 1);
    }
    return dir;
  }
1126220
function mergeUrlWithParams(url, params) {
        params = params || {};
        return _.isEmpty(params) ? url : url + "?" + qs.stringify(params);
    }
1333840
def _merge_params(url, params):
    """"""
    if isinstance(params, dict):
        params = list(params.items())

    scheme, netloc, path, query, fragment = urllib.parse.urlsplit(url)
    url_params = urllib.parse.parse_qsl(query, keep_blank_values=True)
    url_params.extend(params)

    query = _encode_data(url_params)

    return urllib.parse.urlunsplit((scheme, netloc, path, query, fragment))
880460
def _build_url(self, resource, **kwargs):
        # type: (str, **str) -> str
        """"""
        return urljoin(self.api_root, API_PATH[resource].format(**kwargs))
1009309
def url2tmp(self, root, url):
        
        filename = url.rsplit('/', 1)[-1]
        return os.path.join(root, filename)
341786
def concat(urls)
      if !urls.nil?
        converted = urls.map { |url| convert_remote_url( url ) }
        super(converted)
      else
        super(nil)
      end 
    end
1029053
function concatAndResolveUrl(url, concat) {
          const url1 = url.split('/');
          const url2 = concat.split('/');
          const url3 = [];
          for (let i = 0, l = url1.length; i < l; i++) {
            if (url1[i] === '..') {
              url3.pop();
            } else if (url1[i] !== '.') {
              url3.push(url1[i]);
            }
          }
          for (let i = 0, l = url2.length; i < l; i++) {
            if (url2[i] === '..') {
              url3.pop();
            } else if (url2[i] !== '.') {
              url3.push(url2[i]);
            }
          }
          return url3.join('/');
        }
898084
def urljoin(end_with_slash, *args):
        
        last = args[0]
        for i in args[1:]:
            last = '%s/%s' % (last.strip('/'), i.strip('/'))

        if end_with_slash:
            if last[-1] != '/':
                last += '/'
        return last
801379
def join_path(self, *path):
		
		path = self.directory_sep().join(path)
		return self.normalize_path(path)