Merge a dictionary of query parameters into the given URL.
    Ensures all parameters are sorted in dictionary order when returning the URL.
512470
def add_query_parameters_to_url(url, query_parameters):
    
    # Parse the given URL into parts.
    url_parts = urllib.parse.urlparse(url)

    # Parse existing parameters and add new parameters.
    qs_args = urllib.parse.parse_qs(url_parts[4])
    qs_args.update(query_parameters)

    # Sort parameters to ensure consistent order.
    sorted_qs_args = OrderedDict()
    for k in sorted(qs_args.keys()):
        sorted_qs_args[k] = qs_args[k]

    # Encode the new parameters and return the updated URL.
    new_qs = urllib.parse.urlencode(sorted_qs_args, True)
    return urllib.parse.urlunparse(list(url_parts[0:4]) + [new_qs] + list(url_parts[5:]))
1325521
function appendParams(url, specificParams) {
    // Assign default and specific parameters
    var params = Object.assign({}, defaultParams, specificParams);

    // Stringify the querystring params
    var paramsString = qs.stringify(params);

    // Empty params
    if (paramsString === '') {
      return url;
    }

    // Does url contain parameters already?
    var delim = url.includes('?') ? '&' : '?';

    return url + delim + paramsString;
  }
1143335
def _to_url(self):
        
        url = self._target_url

        params = collections.defaultdict(list, copy.deepcopy(self._filters))
        if self._order_by is not None:
            params['sort'] = self._order_by
        for k, vl in self._extra.items():
            params[k] += vl

        if params:
            url += "?" + urllib.parse.urlencode(params, doseq=True)

        return url
667470
def urlencode(params):
    """"""

    # Not doing duck typing here. Will make debugging easier.
    if not isinstance(params, dict):
        raise TypeError("Only dicts are supported.")

    params = flatten(params)

    url_params = OrderedDict()
    for param in params:
        value = param.pop()

        name = parametrize(param)
        if isinstance(value, (list, tuple)):
            name += "[]"

        url_params[name] = value

    return urllib_urlencode(url_params, doseq=True)
1194549
def __append_url_params(self, url, params):
    """"""
    url_parts = list(urlparse(url))
    query = dict(parse_qsl(url_parts[4]))
    query.update(params)
    url_parts[4] = urlencode(query)

    return urlunparse(url_parts)
692531
def merge_parameter_lists(*parameter_definitions):
    
    merged_parameters = {}
    for parameter_list in parameter_definitions:
        for parameter in parameter_list:
            key = (parameter['name'], parameter['in'])
            merged_parameters[key] = parameter
    return merged_parameters.values()
1135980
def add_params_to_uri(uri, params, fragment=False):
    """"""
    sch, net, path, par, query, fra = urlparse.urlparse(uri)
    if fragment:
        fra = add_params_to_qs(fra, params)
    else:
        query = add_params_to_qs(query, params)
    return urlparse.urlunparse((sch, net, path, par, query, fra))
1259727
def url_to_parts(url):
    

    if not url:
        return None

    scheme, netloc, path, query, fragment = _urlsplit(url)

    if not path or path == '/':
        path = []
    else:
        path = path.strip('/').split('/')

    if not query:
        query = {}
    else:
        query = _parse_qs(query)

    return _urllib_parse.SplitResult(scheme, netloc, path, query, fragment)
1338316
def concat_urls(*urls):
    
    normalized_urls = filter(bool, [url.strip('/') for url in urls])
    joined_urls = '/'.join(normalized_urls)
    if not joined_urls:
        return '/'
    return '/{}/'.format(joined_urls)
386686
def _join_url_dir(self, url, *args):
        
        for path in args:
            url = url.rstrip('/') + '/'
            url = urljoin(url, path.lstrip('/'))

        return url
630915
def sort_url_qsl(cls, raw_url, **kwargs):
        
        parsed_url = urlparse(raw_url)
        qsl = parse_qsl(parsed_url.query)
        return cls._join_url(parsed_url, sorted(qsl, **kwargs))
437806
def urljoin (parent, url):
    
    if urlutil.url_is_absolute(url):
        return url
    return urlparse.urljoin(parent, url)
733456
def process_url(self, page_num, page_size, url):
        
        params = dict()
        if page_num is not None:
            url = re.sub('page=\d+', '', url)
            params['page'] = page_num
        if page_size is not None:
            url = re.sub('per_page=\d+', '', url)
            params['per_page'] = page_size
        return params, url
704400
def getQueryParams(url):
    """"""
    query = urlsplit(url)[3]
    out.debug(u'Extracting query parameters from %r (%r)...' % (url, query))
    return cgi.parse_qs(query)
1149089
def urlQueryParser(url, querydict):
    
    address_parse = urlparse(url)
    return urlunparse(address_parse._replace(query=urlencode(querydict)))
494802
def args_to_search_url(arguments)
      query = if arguments[:query].kind_of? Hash
        #multi-field
        arguments[:query].collect {|field, query_value| fielded_query(query_value, field)}.join(" ")
      elsif arguments[:search_field]
        fielded_query(arguments[:query], arguments[:search_field])
      else
        arguments[:query]
      end

      query_url = base_url + "volumes?q=#{CGI.escape  query}"
      if configuration.api_key
        query_url += "&key=#{configuration.api_key}"
      end

      if arguments[:per_page]
        query_url += "&maxResults=#{arguments[:per_page]}"
      end
      if arguments[:start]
        query_url += "&startIndex=#{arguments[:start]}"
      end

      if arguments[:sort] &&
          (defn = sort_definitions[arguments[:sort]]) &&
          (value = defn[:implementation])
        query_url += "&orderBy=#{CGI.escape(value)}"
      end


      return query_url
    end
504276
function(url, param, args) {
        var index;
        var name;
        var urlArgs = '?';

        var i;
        var oldCount;
        var arrayUrl = url.split('/');

        var res = {
            url : '',
            count : 0
        };

        // For each arguments.
        for (index in args) {
            // Create the name, :argument or name from param in routing.
            name = (typeof(param[index]) != 'undefined') ? param[index] : ':'+index;
            i = 0;
            // Saving count each iteration.
            oldCount = res.count;
            for (; i < arrayUrl.length; ++i) {
                // If an argument match.
                if (arrayUrl[i] == name) {
                    // Replace data with the argument value.
                    arrayUrl[i] = args[index];
                    ++res.count
                }
            }
            // If equal, the argument was not a param url, add in get request.
            if (oldCount == res.count) {
                urlArgs = urlArgs + index + '=' + args[index] + '&'
            }
        }
        // Remove the last character '?' if empty or '&' if filled.
        urlArgs = urlArgs.slice(0, -1);
        // Create the new url.
        res.url = arrayUrl.join('/');
        // Add get arguments.
        res.url = res.url+urlArgs;

        // Return result.
        return res
    }