Creates a rgular expression to match this route.
Url param names are stored in `keys` and the `params` are completed with
the default values for url parameters.
765206
function normalizePath(path, keys, params) {
        for (var name in params) {
            var param = params[name];
            if (typeof param == "string" || param instanceof RegExp)
                params[name] = {type: param};
        }

        path = path
            .concat("/?")
            .replace(/\/:([\w.\-_]+)(\*?)/g, function(match, key, wildcard) {
                keys.push(key);
                if (!params[key]) {
                    params[key] = {};
                }
                // url params default to type string and optional=false
                var param = params[key];
                param.type = param.type || "string";
                param.optional = false;

                if (!param.source) param.source = "url";

                if (param.source !== "url")
                    throw new Error(
                        "Url parameters must have 'url' as source but found '" +
                            param.source +
                            "'"
                    );

                if (wildcard) return "(/*)";
                else return "/([^\\/]+)";
            })
            .replace(/([/.])/g, "\\$1")
            .replace(/\*/g, "(.*)");

        return new RegExp("^" + path + "$");
    }
503348
function extractQueryParameters (query) {
  return Object.keys(query.values)
    .reduce((queryParameters, name) => {
      // arrays in routing definitions are not supported
      if (util.isArray(query.values[name])) {
        return queryParameters;
      }

      // escape regular expression characters
      var escaped = query.values[name].replace(EXPRESSION_ESCAPE_REG_EXP, '\\$&');

      // get all occurrences of routing parameters in URI path
      var regExpSource = '^' + escaped.replace(PARAMETER_REG_EXP, URI_QUERY_REPLACEMENT_REG_EXP_SOURCE) + '$';
      var queryParameterMatches = escaped.match(PARAMETER_REG_EXP);

      if (!queryParameterMatches ||
          queryParameterMatches.length === 0) {
        return;
      }

      var parameter = getParameterDescriptor(queryParameterMatches[queryParameterMatches.length - 1]);
      var expression = new RegExp(regExpSource, 'i');
      parameter.map = createUriQueryValueMapper(expression);
      queryParameters[name] = parameter;
      return queryParameters;
    }, Object.create(null));
}
1299091
def convert_regex_to_flask_path(url_path):
    
    for token in ["$"]:
        url_path = url_path.replace(token, "")

    def caller(reg):
        match_name, match_pattern = reg.groups()
        return '<regex("{0}"):{1}>'.format(match_pattern, match_name)

    url_path = re.sub("\(\?P<(.*?)>(.*?)\)", caller, url_path)

    if url_path.endswith("/?"):
        # Flask does own handling of trailing slashes
        url_path = url_path.rstrip("/?")
    return url_path
289932
def match(*args)
      # Localize simple match only if there is no resource scope.
      if @locales and (args.size >= 1) and !parent_resource and
             args.last.is_a?(Hash) # In both variants Hash should be present as last parameter

        # Make deep copy of last argument (Hash)
        options = Marshal.load(Marshal.dump(args.last)) # Dump is dirty but how to make deep cloning easily ? :/

        # Now handle parameters
        if (args.first.is_a?(Hash))
          path, to = options.find { |name, value| name.is_a?(String) }
          options.merge!(:to => to).delete(path)
        else
          path = args[0]
          options[:as] ||= path
        end

        if (options[:as])
          @locales.each do |locale|
            mapping = LocalizedMapping.new(locale, @set, @scope, path, options)
            if mapping.localizable?
              puts("[I18n] > localize %-10s: %40s (%s) => %s" % ['route', options[:as], locale, mapping.path]) if @i18n_verbose
              @set.add_route(*mapping.to_route)
            end
          end

          # Now, create the real match :
          return set_localizable_route(options[:as]) do
            super
          end
        end
      end

      super
    end
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;
}
98202
function createNamedVariables(route, action) {
    return function innerCreateNamedVariables(matchedPath) {
        var convertedArguments;
        var len = -1;
        var restOfArgs = slice(arguments, 1);
        var isJSONObject = !isArray(matchedPath);

        // A set uses a json object
        if (isJSONObject) {
            restOfArgs = [];
            convertedArguments = matchedPath;
        }

        // Could be an array of pathValues for a set operation.
        else if (isPathValue(matchedPath[0])) {
            convertedArguments = [];

            matchedPath.forEach(function(pV) {
                pV.path = convertPathToRoute(pV.path, route);
                convertedArguments[++len] = pV;
            });
        }

        // else just convert and assign
        else {
            convertedArguments =
                convertPathToRoute(matchedPath, route);
        }
        return action.apply(this, [convertedArguments].concat(restOfArgs));
    };
}
1172450
function routeIsActive(pathname, routes, params) {
  var remainingPathname = pathname,
      paramNames = [],
      paramValues = [];

  // for...of would work here but it's probably slower post-transpilation.
  for (var i = 0, len = routes.length; i < len; ++i) {
    var route = routes[i];
    var pattern = route.path || '';

    if (pattern.charAt(0) === '/') {
      remainingPathname = pathname;
      paramNames = [];
      paramValues = [];
    }

    if (remainingPathname !== null && pattern) {
      var matched = (0, _PatternUtils.matchPattern)(pattern, remainingPathname);
      if (matched) {
        remainingPathname = matched.remainingPathname;
        paramNames = [].concat(paramNames, matched.paramNames);
        paramValues = [].concat(paramValues, matched.paramValues);
      } else {
        remainingPathname = null;
      }

      if (remainingPathname === '') {
        // We have an exact match on the route. Just check that all the params
        // match.
        // FIXME: This doesn't work on repeated params.
        return paramNames.every(function (paramName, index) {
          return String(paramValues[index]) === String(params[paramName]);
        });
      }
    }
  }

  return false;
}
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();
    }
1003747
function (route) {
        var staticPrefix = null;
        var hostVariables = [];
        var pathVariables = [];
        var variables = [];
        var tokens = [];
        var regex = null;
        var hostRegex = null;
        var hostTokens = [];
        var host;

        if ('' !== (host = route.domain())) {
            var result = compilePattern(route, host, true);

            hostVariables = result['variables'];
            variables = variables.concat(hostVariables);

            hostTokens = result['tokens'];
            hostRegex = result['regex'];
        }

        var path = route.getPath();

        result = compilePattern(route, path, false);

        staticPrefix = result['staticPrefix'];

        pathVariables = result['variables'];
        variables = variables.concat(pathVariables);

        tokens = result['tokens'];
        regex = result['regex'];

        return new CompiledRoute(
            staticPrefix,
            regex,
            tokens,
            pathVariables,
            hostRegex,
            hostTokens,
            hostVariables,
            _.uniq(variables)
        );
    }
807346
def pull_url_pairs(params)
      url.keys.map {|k| [k, params.delete(k) || params.delete(k.to_sym)] }
    end
441684
function compileStringRouteExpression (routeExpression) {
  var routeUri = new URI(routeExpression);
  routeUri.path = module.exports.removeEndSlash(routeUri.path);
  if (!routeUri) {
    return null;
  }

  // escape regular expression characters
  var escaped = routeUri.path.replace(
    EXPRESSION_ESCAPE_REG_EXP, '\\$&'
  );

  // get all occurrences of routing parameters in URI path
  var regExpSource = '^' + escaped.replace(PARAMETER_REG_EXP, URI_PATH_REPLACEMENT_REG_EXP_SOURCE) + '$';
  var expression = new RegExp(regExpSource, 'i');
  var pathParameterMatches = escaped.match(PARAMETER_REG_EXP);
  var pathParameters = pathParameterMatches ? pathParameterMatches.map(getParameterDescriptor) : null;

  var pathMapper = pathParameters ? createUriPathMapper(expression, pathParameters) : null;
  var queryMapper = routeUri.query ? createUriQueryMapper(routeUri.query) : null;

  return {
    expression: expression,
    map: uri => {
      var args = Object.create(null);

      if (pathMapper) {
        pathMapper(uri.path, args);
      }

      if (queryMapper && uri.query) {
        queryMapper(uri.query.values, args);
      }

      return args;
    }
  };
}
1126906
def prepare_params(params)
      # Create a new hash in case is a HashWithIndifferentAccess (keys are
      # always a String)
      params = Utils.symbolize_keys(Hash[params])
      # Only pull out the relevant parameters, other won't be included in the
      # signature so will cause false negatives
      keys = [:resource_id, :resource_type, :resource_uri, :state, :signature]
      params = Hash[params.select { |k,v| keys.include? k }]
      (keys - [:state]).each do |key|
        raise ArgumentError, "Parameters missing #{key}" if !params.key?(key)
      end
      params
    end
464542
def match(path)
       if match = @regexp.match(path)
         params = {}
         @named.each_with_index { |name, i| params[name] = match[i + 1] } if @type == :handlers
         {
             path: path,
             title: self.flags.fetch(:title){nil},
             params: params,
             route: self
         }
       else
         false
       end
    end
299058
function generatePath(route, params) {
    return route.pattern.replace(nameOrSplatParam, function(_, name) { return params[name]; });
  }
1129260
function tokensToRegExp (tokens, keys, options) {
  if (!isarray(keys)) {
    options = /** @type {!Object} */ (keys || options);
    keys = [];
  }

  options = options || {};

  var strict = options.strict;
  var end = options.end !== false;
  var route = '';

  // Iterate over the tokens and create our regexp string.
  for (var i = 0; i < tokens.length; i++) {
    var token = tokens[i];

    if (typeof token === 'string') {
      route += escapeString(token);
    } else {
      var prefix = escapeString(token.prefix);
      var capture = '(?:' + token.pattern + ')';

      keys.push(token);

      if (token.repeat) {
        capture += '(?:' + prefix + capture + ')*';
      }

      if (token.optional) {
        if (!token.partial) {
          capture = '(?:' + prefix + '(' + capture + '))?';
        } else {
          capture = prefix + '(' + capture + ')?';
        }
      } else {
        capture = prefix + '(' + capture + ')';
      }

      route += capture;
    }
  }

  var delimiter = escapeString(options.delimiter || '/');
  var endsWithDelimiter = route.slice(-delimiter.length) === delimiter;

  // In non-strict mode we allow a slash at the end of match. If the path to
  // match already ends with a slash, we remove it for consistency. The slash
  // is valid at the end of a path match, not in the middle. This is important
  // in non-ending mode, where "/test/" shouldn't match "/test//route".
  if (!strict) {
    route = (endsWithDelimiter ? route.slice(0, -delimiter.length) : route) + '(?:' + delimiter + '(?=$))?';
  }

  if (end) {
    route += '$';
  } else {
    // In non-ending mode, we need the capturing groups to match as much as
    // possible by using a positive lookahead to the end or next path segment.
    route += strict && endsWithDelimiter ? '' : '(?=' + delimiter + '|$)';
  }

  return attachKeys(new RegExp('^' + route, flags(options)), keys)
}
1091548
function extractParams(route, path) {
    var vals = route.regex.exec(path).slice(1), params = {}, i, n;

    for (i = 0, n = route.names.length; i < n; i++) {
      params[route.names[i]] = vals[i];
    }

    return params;
  }
89651
def make_router():
    
    global router
    routings = [
        ('GET', '^/$', index),
        ('GET', '^/api/?$', index),
        ('POST', '^/api/1/calculate/?$', calculate.api1_calculate),
        ('GET', '^/api/2/entities/?$', entities.api2_entities),
        ('GET', '^/api/1/field/?$', field.api1_field),
        ('GET', '^/api/1/formula/(?P<name>[^/]+)/?$', formula.api1_formula),
        ('GET', '^/api/2/formula/(?:(?P<period>[A-Za-z0-9:-]*)/)?(?P<names>[A-Za-z0-9_+-]+)/?$', formula.api2_formula),
        ('GET', '^/api/1/parameters/?$', parameters.api1_parameters),
        ('GET', '^/api/1/reforms/?$', reforms.api1_reforms),
        ('POST', '^/api/1/simulate/?$', simulate.api1_simulate),
        ('GET', '^/api/1/swagger$', swagger.api1_swagger),
        ('GET', '^/api/1/variables/?$', variables.api1_variables),
        ]
    router = urls.make_router(*routings)
    return router