Reverse parameter remappings for URL construction.
551784
def MapParamNames(params, request_type):
    """"""
    return [encoding.GetCustomJsonFieldMapping(request_type, json_name=p) or p
            for p in params]
708210
def urlparse(uri):
    """"""
    scheme, netloc, path, params, query, fragment = parse.urlparse(uri)
    return (
        parse.unquote(scheme),
        parse.unquote(netloc),
        parse.unquote(path),
        parse.unquote(params),
        parse.unquote(query),
        parse.unquote(fragment)
    )
246222
def _relIndexLink(self):
        """"""
        return os.path.join("..", os.path.basename(self.pathname), "index.html")
62591
function createUriPathMapper (expression, parameters) {
  return (uriPath, args) => {
    var matches = uriPath.match(expression);
    if (!matches || matches.length < 2) {
      return args;
    }

    // start with second match because first match is always
    // the whole URI path
    matches = matches.splice(1);

    parameters.forEach((parameter, index) => {
      var value = matches[index];

      try {
        value = decodeURIComponent(value);
      } catch (e) {
        // nothing to do
      }

      args[parameter.name] = value;
    });
  };
}
257677
def reverse(viewname, urlconf=None, args=None, kwargs=None, prefix=None):
    """"""
    prefixer = get_url_prefix()

    if prefixer:
        prefix = prefix or '/'
    url = django_reverse(viewname, urlconf, args, kwargs, prefix)
    if prefixer:
        url = prefixer.fix(url)

    # Ensure any unicode characters in the URL are escaped.
    return iri_to_uri(url)
1361889
function sgTrackingUrlMapper(url, data) {
  // In our development system urls start with /php/shopgate/ always
  const developmentPath = '/php/shopgate/';
  const appRegex = /sg_app_resources\/[0-9]*\//;

  // Build regex that will remove all blacklisted paramters
  let regex = '';
  urlParameterBlacklist.forEach((entry) => {
    regex += `((\\?|^){0,1}(${entry}=.*?(&|$)))`;
    regex += '|';
  });
  const params = url.indexOf('?') !== -1 ? url.split('?')[1] : '';
  let urlParams = params.replace(new RegExp(regex, 'g'), '');
  urlParams = urlParams === '' ? '' : `?${urlParams.replace(/&$/, '')}`;

  // Get rid of hash and app urls
  let urlPath = url.split('?')[0].split('#')[0].replace(appRegex, '');

  // Get path from url
  if (url.indexOf(developmentPath) !== -1) {
    urlPath = urlPath.substring(urlPath.indexOf(developmentPath) + developmentPath.length);
  } else if (urlPath.indexOf('http') !== -1) {
    urlPath = urlPath.substring(urlPath.indexOf('/', urlPath.indexOf('//') + 2) + 1);
  } else {
    urlPath = urlPath.substring(1);
  }

  // Get action from path
  const action = urlPath.substring(
    0,
    ((urlPath.indexOf('/') !== -1) ? (urlPath.indexOf('/')) : undefined)
  );

  // If no mapping function is available for the action, continue
  if (typeof mapping[action] === 'undefined') {
    return {
      public: urlPath + urlParams,
      private: action,
    };
  }

  // Call mapping function and return its result
  const pathWithoutAction = urlPath.substring(action.length + 1);
  let pathWithoutActionArray = [];

  if (pathWithoutAction.length !== 0) {
    pathWithoutActionArray = pathWithoutAction.split('/');
  }

  const mappedUrls = mapping[action](pathWithoutActionArray, data || {});

  if (Array.isArray(mappedUrls)) {
    return {
      public: mappedUrls[1] + urlParams,
      private: mappedUrls[0],
    };
  }

  return {
    public: mappedUrls + urlParams,
    private: mappedUrls,
  };
}
532038
def parse_search_url(url):
    """"""

    config = {}

    url = urlparse.urlparse(url)

    # Remove query strings.
    path = url.path[1:]
    path = path.split('?', 2)[0]

    if url.scheme in SEARCH_SCHEMES:
        config["ENGINE"] = SEARCH_SCHEMES[url.scheme]

    if url.scheme in USES_URL:
        config["URL"] = urlparse.urlunparse(("http",) + url[1:])

    if url.scheme in USES_INDEX:
        if path.endswith("/"):
            path = path[:-1]

        split = path.rsplit("/", 1)

        if len(split) > 1:
            path = split[:-1]
            index = split[-1]
        else:
            path = ""
            index = split[0]

        config.update({
            "URL": urlparse.urlunparse(("http",) + url[1:2] + (path,) + url[3:]),
            "INDEX_NAME": index,
        })

    if url.scheme in USES_PATH:
        config.update({
            "PATH": path,
        })

    return config
307459
def parse(url):
    """"""

    config = {}

    url = urlparse.urlparse(url)

    # Remove query strings.
    path = url.path[1:]
    path = path.split('?', 2)[0]

    if url.scheme in SCHEMES:
        config["ENGINE"] = SCHEMES[url.scheme]

    if url.scheme in USES_URL:
        config["URL"] = urlparse.urlunparse(("http",) + url[1:])

    if url.scheme in USES_INDEX:
        if path.endswith("/"):
            path = path[:-1]

        split = path.rsplit("/", 1)

        if len(split) > 1:
            path = split[:-1]
            index = split[-1]
        else:
            path = ""
            index = split[0]

        config.update({
            "URL": urlparse.urlunparse(("http",) + url[1:2] + (path,) + url[3:]),
            "INDEX_NAME": index,
        })

    if url.scheme in USES_PATH:
        config.update({
            "PATH": path,
        })

    return config
300988
function (url) {
            return url
                .replace(/[\/]+/g, '/')
                .replace(/\/\?/g, '?')
                .replace(/\/\#/g, '#')
                .replace(/\:\//g, '://');
        }
344057
def get_url_parameters(self):
        """"""
        url_fields = {}
        for field in self.url_fields:
            url_fields[field] = getattr(self, field)
        return url_fields
992183
def reverse_lazy_with_query(named_url,**kwargs):
    ""
    q = QueryDict('',mutable=True)
    q.update(kwargs)
    return '{}?{}'.format(reverse_lazy(named_url),q.urlencode())
275890
def prep(link):
    '''
    
    '''
    s, p, o = link[:3]
    s = URIRef(s)
    p = URIRef(p)
    o = URIRef(o) if isinstance(o, I) else Literal(o)
    return s, p, o
1153110
def parse_url(request, url):
    """"""
    try:
        validate = URLValidator()
        validate(url)
    except ValidationError:
        if url.startswith('/'):
            host = request.get_host()
            scheme = 'https' if request.is_secure() else 'http'
            url = '{scheme}://{host}{uri}'.format(scheme=scheme,
                                                  host=host,
                                                  uri=url)
        else:
            url = request.build_absolute_uri(reverse(url))
    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)
1340225
function customNormalizeUrl (url) {
  const [urlWithoutFragment, fragment] = url.split('#')
  return [normalizeUrl(urlWithoutFragment) + '/', fragment].filter(Boolean).join('#')
}
569043
function replaceUrlParameters (url, urlParameters) {
  var replacedUrl = url;
  for (var urlParameter in urlParameters) {
    var regex = (urlParameter === '*'
      ? new RegExp('\\*') // The first occurrence of the literal character '*'.
      : new RegExp(':' + urlParameter, 'g')); // All occurrences of `:param`.
    var urlValue = urlParameters[urlParameter];
    replacedUrl = replacedUrl.replace(regex, urlValue);
  }
  return replacedUrl;
}
759999
def makeMNBaseURL(url):
    """"""
    o = urllib.parse.urlparse(url, scheme=d1_common.const.DEFAULT_MN_PROTOCOL)
    if o.netloc and o.path:
        netloc = o.netloc
        path = o.path
    elif o.netloc:
        netloc = o.netloc
        path = d1_common.const.DEFAULT_MN_PATH
    elif o.path:
        s = o.path.split('/', 1)
        netloc = s[0]
        if len(s) == 1:
            path = d1_common.const.DEFAULT_MN_PATH
        else:
            path = s[1]
    else:
        netloc = d1_common.const.DEFAULT_MN_HOST
        path = d1_common.const.DEFAULT_MN_PATH
    return urllib.parse.urlunparse(
        (o.scheme, netloc, path, o.params, o.query, o.fragment)
    )