Append any optional parameters to the URL

@param appendToResponse String array to convert to a comma list
@return comma separated list
14205
public String toList(final String[] appendToResponse) {
        StringBuilder sb = new StringBuilder();
        boolean first = Boolean.TRUE;
        for (String append : appendToResponse) {
            if (first) {
                first = Boolean.FALSE;
            } else {
                sb.append(",");
            }
            sb.append(append);
        }

        return sb.toString();
    }
1074439
public static String formatParamList(String ... params) {
		StringBuilder s = new StringBuilder();
		for(String p : params) {
			if (s.length() != 0) {
				s.append(", ");
			}
			s.append(p);
		}
		return s.toString();
	}
900078
protected void appendMapKey(StringBuilder buffer, Map<String, Object> params) {
        if (params==null || params.isEmpty()) {
            buffer.append(EMPTY_MAP_STRING);
            buffer.append(OPENING_BRACKET);
        } else {
            buffer.append(OPENING_BRACKET);
            Map map = new LinkedHashMap<>(params);
            final String requestControllerName = getRequestStateLookupStrategy().getControllerName();
            if (map.get(UrlMapping.ACTION) != null && map.get(UrlMapping.CONTROLLER) == null && map.get(RESOURCE_PREFIX) == null) {
                Object action = map.remove(UrlMapping.ACTION);
                map.put(UrlMapping.CONTROLLER, requestControllerName);
                map.put(UrlMapping.ACTION, action);
            }
            if (map.get(UrlMapping.NAMESPACE) == null && map.get(UrlMapping.CONTROLLER) == requestControllerName) {
                String namespace = getRequestStateLookupStrategy().getControllerNamespace();
                if (GrailsStringUtils.isNotEmpty(namespace)) {
                    map.put(UrlMapping.NAMESPACE, namespace);
                }
            }
            boolean first = true;
            for (Object o : map.entrySet()) {
                Map.Entry entry = (Map.Entry) o;
                Object value = entry.getValue();
                if (value == null) continue;
                first = appendCommaIfNotFirst(buffer, first);
                Object key = entry.getKey();
                if (RESOURCE_PREFIX.equals(key)) {
                    value = getCacheKeyValueForResource(value);
                }
                appendKeyValue(buffer, map, key, value);
            }
        }
        buffer.append(CLOSING_BRACKET);
    }
516998
protected function appendParamsToUrl(string $url, array $params): string
    {
        if (empty($params['_fields'])) {
            unset($params['_fields']);
        }

        if (empty($params)) {
            return $url;
        }

        // If the _fields param is set transform it to a single string so that
        // it's not urlencoded as an array
        if (isset($params['_fields']) && \is_array($params['_fields'])) {
            $params['_fields'] = array_unique(array_merge($params['_fields'], ['id']));
            $params['_fields'] = implode(',', $params['_fields']);
        }

        // If there is no question mark in the URL we can just add the params
        // to the query string and exit early
        if (strpos($url, '?') === false) {
            return $url . '?' . http_build_query($params, '', '&');
        }

        list($path, $query) = explode('?', $url, 2);

        parse_str($query, $existingParams);

        $params = array_merge($params, $existingParams);

        return $path . '?' . http_build_query($params, '', '&');
    }
856956
public static function appendParamsToUrl($url, $params)
    {
        if (empty($params)) {
            return $url;
        }

        $getParams =  http_build_query($params, null, '&');

        return $url . '?' . $getParams;
    }
402757
static void addQueryParams(Set<Entry<String, Object>> entrySet, StringBuilder buf) {
    // (similar to UrlEncodedContent)
    boolean first = true;
    for (Map.Entry<String, Object> nameValueEntry : entrySet) {
      Object value = nameValueEntry.getValue();
      if (value != null) {
        String name = CharEscapers.escapeUriQuery(nameValueEntry.getKey());
        if (value instanceof Collection<?>) {
          Collection<?> collectionValue = (Collection<?>) value;
          for (Object repeatedValue : collectionValue) {
            first = appendParam(first, buf, name, repeatedValue);
          }
        } else {
          first = appendParam(first, buf, name, value);
        }
      }
    }
  }
219570
final URI spliceUrl(String resource, Map<String, String> parameters) throws RestEndpointIOException {
        try {
            URIBuilder builder;
            if (!Strings.isNullOrEmpty(baseUrl)) {
                builder = new URIBuilder(baseUrl);
                builder.setPath(builder.getPath() + resource);
            } else {
                builder = new URIBuilder(resource);
            }
            for (Entry<String, String> parameter : parameters.entrySet()) {
                builder.addParameter(parameter.getKey(), parameter.getValue());
            }
            return builder.build();
        } catch (URISyntaxException e) {
            throw new RestEndpointIOException(
                    "Unable to builder URL with base url '" + baseUrl + "' and resouce '" + resource + "'", e);
        }
    }
796094
public UrlStringBuilder addParameter(String name, String... values) {
        this.addParameter(name, values != null ? Arrays.asList(values) : null);
        return this;
    }
1313939
@Action(name = "List Prepender",
            outputs = {
                    @Output(RESPONSE),
                    @Output(RETURN_RESULT),
                    @Output(RETURN_CODE)
            },
            responses = {
                    @Response(text = SUCCESS, field = RETURN_CODE, value = RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL),
                    @Response(text = FAILURE, field = RETURN_CODE, value = RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, isOnFail = true, isDefault = true)
            })
    public Map<String, String> prependElement(@Param(value = LIST, required = true) String list,
                                              @Param(value = ELEMENT, required = true) String element,
                                              @Param(value = DELIMITER) String delimiter) {
        Map<String, String> result = new HashMap<>();
        try {
            StringBuilder sb = new StringBuilder();
            sb = StringUtils.isEmpty(list) ? sb.append(element) : sb.append(element).append(delimiter).append(list);
            result.put(RESPONSE, SUCCESS);
            result.put(RETURN_RESULT, sb.toString());
            result.put(RETURN_CODE, RETURN_CODE_SUCCESS);
        } catch (Exception e) {
            result.put(RESPONSE, FAILURE);
            result.put(RETURN_RESULT, e.getMessage());
            result.put(RETURN_CODE, RETURN_CODE_FAILURE);
        }
        return result;
    }
81186
def add_url_parameters(url, parameters):
        
        scheme, netloc, path, query_string, fragment = urlsplit(url)
        query = parse_qs(query_string)
        query.update(parameters)
        return urlunsplit((scheme, netloc, path, urlencode(query), fragment))
1278997
protected void appendParameters(StringBuilder buffer,String parameters)
    {
        if((parameters!=null)&&(parameters.length()>0))
        {
            String updatedParameters=parameters;
            if(parameters.startsWith("?"))
            {
                updatedParameters=parameters.substring(1);
            }
            
            if(updatedParameters.length()>0)
            {
                int currentLength=buffer.length();
                if((currentLength>0)&&(buffer.charAt(currentLength-1)=='/'))
                {
                    int length=currentLength;
                    buffer.delete(length-1,length);
                }
                
                //add separator
                buffer.append("?");
    
                try
                {
                    String[] parameterPairs=updatedParameters.split("&");
                    int amount=parameterPairs.length;
                    String parameterPair=null;
                    String[] values=null;
                    boolean addedParameters=false;
                    for(int index=0;index<amount;index++)
                    {
                        //get next element
                        parameterPair=parameterPairs[index];
                        
                        //split to key/value
                        values=parameterPair.split("=");
                        if(values.length==2)
                        {
                            if(addedParameters)
                            {
                                buffer.append("&");
                            }
                            
                            buffer.append(URLEncoder.encode(values[0],"UTF-8"));
                            buffer.append("=");
                            buffer.append(URLEncoder.encode(values[1],"UTF-8"));
                            
                            //set flag
                            addedParameters=true;
                        }
                    }
                }
                catch(Exception exception)
                {
                    throw new FaxException("Unable to encode parameters.",exception);
                }
            }
        }
    }
1351371
function buildUrl(urlPattern, customParams) {
    var url = formatUrl.apply(null, urlPattern);

    url = appendParams(url, customParams);
    return url;
  }
396244
public WebTarget appendPathAndQueryParameters(final WebTarget webTarget) {
    ArgumentChecker.notNull(webTarget, "webTarget");
    WebTarget resultTarget = webTarget;
    resultTarget = resultTarget.path(MULTI_SET_NAME + EXTENSION);
    resultTarget = resultTarget.queryParam(COLUMNS_PARAM, buildCodeList(_quandlCodeRequests));
    if (_startDate != null) {
      resultTarget = resultTarget.queryParam(START_DATE_PARAM, _startDate.toString());
    }
    if (_endDate != null) {
      resultTarget = resultTarget.queryParam(END_DATE_PARAM, _endDate.toString());
    }
    if (_frequency != null) {
      resultTarget = resultTarget.queryParam(FREQUENCY_PARAM, _frequency.getQuandlString());
    }
    if (_maxRows != null) {
      resultTarget = resultTarget.queryParam(MAX_ROWS_PARAM, _maxRows);
    }
    if (_transform != null) {
      resultTarget = resultTarget.queryParam(TRANSFORM_PARAM, _transform.getQuandlString());
    }
    if (_sortOrder != null) {
      resultTarget = resultTarget.queryParam(SORT_ORDER_PARAM, _sortOrder.getQuandlString());
    }
    return resultTarget;
  }
776852
protected static final QueryMap parseApiRequestQueryParams(String queryString) {
        QueryMap rval = new QueryMap();

        if (queryString != null) {
            try {
                String[] pairSplit = queryString.split("&"); //$NON-NLS-1$
                for (String paramPair : pairSplit) {
                    int idx = paramPair.indexOf("="); //$NON-NLS-1$
                    String key, value;
                    if (idx != -1) {
                        key =  URLDecoder.decode(paramPair.substring(0, idx), "UTF-8"); //$NON-NLS-1$
                        value = URLDecoder.decode(paramPair.substring(idx + 1), "UTF-8"); //$NON-NLS-1$
                    } else {
                        key = URLDecoder.decode(paramPair, "UTF-8"); //$NON-NLS-1$
                        value = null;
                    }
                    rval.add(key,  value);
                }
            } catch (UnsupportedEncodingException e) {
                throw new RuntimeException(e);
            }

        }

        return rval;
    }
594309
public UrlStringBuilder addParameters(String namespace, Map<String, List<String>> parameters) {
        for (final String name : parameters.keySet()) {
            Validate.notNull(name, "parameter map cannot contain any null keys");
        }

        for (final Map.Entry<String, List<String>> newParamEntry : parameters.entrySet()) {
            final String name = newParamEntry.getKey();
            final List<String> values = this.copy(newParamEntry.getValue());

            this.parameters.put(namespace + name, values);
        }
        return this;
    }
600804
public static String appendArray(final String value, final String[] appends) {
        validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
        if (appends == null || appends.length == 0) {
            return value;
        }
        StringJoiner joiner = new StringJoiner("");
        for (String append : appends) {
            joiner.add(append);
        }
        return value + joiner.toString();
    }
201385
private function buildUrl($endpoint, array $additional_parameters = []) {
    // Build base domain URI.
    $base = ($this->use_stage ? 'stg.' : '') . $this->domain;
    // Build initial array of parameters.
    $parameters = [
      'passKey=' . $this->apiKey,
      'ApiVersion=' . self::$api_version,
    ];

    // Adding additional parameters?
    if (!empty($additional_parameters)) {
      // Loop through each parameter to build out correctly.
      foreach ($additional_parameters as $param_name => $param_value) {
        // If value is an array, then passing multiple sub parameter values.
        if (is_array($param_value)) {
          // Build each sub parameter.
          foreach ($param_value as $sub_param_name => $sub_param_value) {
            // Add to parameters array.
            $sub_param_value = is_array($sub_param_value) ? implode(",", $sub_param_value) : $sub_param_value;
            $parameters[] = $param_name . '=' . $sub_param_name . ':' . $sub_param_value;
          }
        }
        // Else it is just a single value parameter.
        else {
          // Add to parameters array.
          $parameters[] = $param_name . '=' . $param_value;
        }
      }
    }

    // Implode all of the parameters.
    $parameters = implode('&', $parameters);

    // return the built url.
    return $base . '/' . $endpoint . '.json?' . $parameters;
  }