Helper method to build an {@link URL} from a baseUri and request parameters

@param url    Base {@link URL}
@param params request parameters
@return URI
507334
private URL buildUriWithParameters(URL url, Map<String, String> params) throws URISyntaxException, MalformedURLException {
        if (params == null || params.isEmpty()) {
            return url;
        }
        URIBuilder uriBuilder = new URIBuilder(url.toURI());
        for (String paramName : params.keySet()) {
            uriBuilder.addParameter(paramName, params.get(paramName));
        }
        return uriBuilder.build().toURL();
    }
343320
public ParallelTaskBuilder prepareHttpOptions(String url) {
        reinitIfClosed();
        ParallelTaskBuilder cb = new ParallelTaskBuilder();
        cb.getHttpMeta().setHttpMethod(HttpMethod.OPTIONS);
        cb.getHttpMeta().setRequestUrlPostfix(url);
        return cb;

    }
788056
public static URL getUrl(String url) {
    try {
      return new URL(url);
    } catch (MalformedURLException e) {
      throw new RuntimeException(e);
    }
  }
1204681
private function makeUri($url, $params = array())
    {
        $uri = \GuzzleHttp\uri_template($this->endpoint, array_merge($this->defaults, $params));
        $uri = new Psr7\Uri($uri);

        // All arguments must be urlencoded (as per RFC 1738).
        $query = Psr7\build_query($params, PHP_QUERY_RFC1738);
        $uri = $uri->withQuery($query);

        return Psr7\Uri::withQueryValue($uri, 'url', $url);
    }
842644
public ParameterParser getUrlParamParser(String url) {
		List<Context> contexts = getContextsForUrl(url);
		if (contexts.size() > 0) {
			return contexts.get(0).getUrlParamParser();
		}
		return this.defaultParamParser;
	}
939240
public String buildUrl(String path, List<Pair> queryParams) {
        final StringBuilder url = new StringBuilder();
        url.append(basePath).append(path);

        if (queryParams != null && !queryParams.isEmpty()) {
            // support (constant) query string in `path`, e.g. "/posts?draft=1"
            String prefix = path.contains("?") ? "&" : "?";
            for (Pair param : queryParams) {
                if (param.getValue() != null) {
                    if (prefix != null) {
                        url.append(prefix);
                        prefix = null;
                    } else {
                        url.append("&");
                    }
                    String value = parameterToString(param.getValue());
                    url.append(escapeString(param.getName())).append("=").append(escapeString(value));
                }
            }
        }

        return url.toString();
    }
236322
public URI baseURL() {
        StringBuilder b = new StringBuilder()
                .append(protocol())
                .append(host())
                .append(":")
                .append(port())
                .append("/")
                .append(versionPrefix())
                .append("/");
        try {
            return new URI(b.toString());
        } catch (URISyntaxException e) {
            throw new IllegalArgumentException("Unable to construct a base URL for the API", e);
        }
    }
536827
public static function createAbsolute($url, array $params = array())
    {
        $url = self::addParams($url, $params);
        $url = ltrim($url, '/');
        $baseUrl = app()->request->getBaseUrl();

        return $baseUrl.'/'.$url;
    }
81556
function urlBuilder(params) {
  var builtUrl = params.base;

  builtUrl += '?';

  if (params.apiKey) {
    builtUrl += 'key=' + params.apiKey + '&';
  }

  if (params.client) {
    builtUrl += 'client=' + params.client + '&';
  }

  if (params.libraries.length > 0) {
    builtUrl += 'libraries=';

    params.libraries.forEach(function(library, index) {
      builtUrl += library;

      if (index !== params.libraries.length - 1) {
        builtUrl += ',';
      }
    });

    builtUrl += '&';
  }

  if (params.language) {
    builtUrl += 'language=' + params.language + '&';
  }

  if (params.version) {
    builtUrl += 'v=' + params.version + '&';
  }

  builtUrl += 'callback=' + params.callback;

  return builtUrl;
}
627371
public RequestBuilder get(final String url) {

    checkNotNull(url, "url may not be null");
    final AsyncHttpClient.BoundRequestBuilder ningRequestBuilder = asyncHttpClient.prepareGet(url);
    return createNewRequestBuilder(url, ningRequestBuilder);
  }
933445
public static String newUrl(final String baseUrl, 
        final Map<String, String> paramMap)
        {
        final StringBuilder sb = new StringBuilder();
        sb.append(baseUrl);
        sb.append(getUrlParameters(paramMap, true));
        return sb.toString();
        }
661350
public HttpRequest buildGetRequest(GenericUrl url) throws IOException {
    return buildRequest(HttpMethods.GET, url, null);
  }
872630
private static String makeBaseUri(URL url) {
		String r = url.getProtocol().toLowerCase() + "://" +
				url.getHost().toLowerCase();
		if ((url.getProtocol().equalsIgnoreCase("http") &&
				url.getPort() != -1 && url.getPort() != 80) ||
			(url.getProtocol().equalsIgnoreCase("https") &&
					url.getPort() != -1 && url.getPort() != 443)) {
			r += ":" + url.getPort();
		}
		return r;
	}
399417
protected URI buildUri(final String path, final List<NameValuePair> queryStringParams) {
        final StringBuilder sb = new StringBuilder();
        
        sb.append(path);
        if (queryStringParams != null && queryStringParams.size() > 0) {
            sb.append("?").append(URLEncodedUtils.format(queryStringParams, "UTF-8"));
        }

        try {
            return new URI(sb.toString());
        } catch (final URISyntaxException e) {
            throw new IllegalStateException("Invalid uri", e);
        }
    }
239702
public static URI appendUri(URI baseUri, String... pathComponents) {
        StringBuilder builder = new StringBuilder(baseUri.toASCIIString());
        for (String path : pathComponents) {
            if (path != null && path.length() > 0) {
                path = normalizePath(path);
                if (path.startsWith("/")) {
                    if (builder.charAt(builder.length() - 1) == '/') {
                        builder.setLength(builder.length() - 1);
                    }
                } else {
                    if (builder.charAt(builder.length() - 1) != '/') {
                        builder.append('/');
                    }
                }
                builder.append(path);
            }
        }
        try {
            return new URI(builder.toString());
        } catch (URISyntaxException e) {
            throw new RuntimeException("Unexpected error", e);
        }
    }
688452
public URI build() {
        try {
            String uriString = String.format("%s%s", baseUri.toASCIIString(),
                    (path.isEmpty() ? "" : path));
            if(qParams != null && qParams.size() > 0) {
                //Add queries together if both exist
                if(!completeQuery.isEmpty()) {
                    uriString = String.format("%s?%s&%s", uriString,
                            getJoinedQuery(qParams.getParams()),
                            completeQuery);
                } else {
                    uriString = String.format("%s?%s", uriString,
                            getJoinedQuery(qParams.getParams()));
                }
            } else if(!completeQuery.isEmpty()) {
                uriString = String.format("%s?%s", uriString, completeQuery);
            }

            return new URI(uriString);
        } catch (URISyntaxException e) {
            throw new IllegalArgumentException(e);
        }
    }
949039
public URI expand(Object... parameters) {

		if (TemplateVariables.NONE.equals(variables)) {
			return URI.create(baseUri);
		}

		org.springframework.web.util.UriTemplate baseTemplate = new org.springframework.web.util.UriTemplate(baseUri);
		UriComponentsBuilder builder = UriComponentsBuilder.fromUri(baseTemplate.expand(parameters));
		Iterator<Object> iterator = Arrays.asList(parameters).iterator();

		for (TemplateVariable variable : getOptionalVariables()) {

			Object value = iterator.hasNext() ? iterator.next() : null;
			appendToBuilder(builder, variable, value);
		}

		return builder.build().toUri();
	}