Applies standard regexp patterns to an incoming URI route.

@param string $route

@return string
184353
private function prepareRouteRegexp(string $route): string
    {
        if (!array_key_exists($route, self::$parsed_regexp)) {
            self::$parsed_regexp[$route] = preg_replace(array_keys($this->regexp_map), array_values($this->regexp_map), $route);
        }
        return self::$parsed_regexp[$route];
    }
629514
function(route) {
      route = route.replace(escapeRegExp, '\\$&')
                   .replace(optionalParam, '(?:$1)?')
                   .replace(namedParam, '([^\/]+)')
                   .replace(splatParam, '(.*?)');
      return new RegExp('^' + route + '$');
    }
962882
private function mapRoute2IndexKey($route)
    {
        $route = rtrim($route, "/");

        if (key_exists($route, $this->index)) {
            return $route;
        } elseif (empty($route) && key_exists("index", $this->index)) {
            return "index";
        } elseif (key_exists($route . "/index", $this->index)) {
            return "$route/index";
        }

        return false;
    }
1247296
protected function compile(&$route)
    {
        if ($route['regex']) {
            return $route;
        }

        $regex = preg_replace('#[.\+*?[^\]${}=!|:-]#', '\\\\$0', $route['pattern']);

        $regex = str_replace(array('(', ')'), array('(?:', ')?'), $regex);

        $regex = str_replace(array('<', '>'), array('(?P<', '>.+?)'), $regex);

        if ($route['rules']) {
            $search = $replace = array();
            foreach ($route['rules'] as $key => $rule) {
                $search[] = '<' . $key . '>.+?';
                $replace[] = '<' . $key . '>' . $rule;
            }
            $regex = str_replace($search, $replace, $regex);
        }

        $route['regex'] = '#^' . $regex . '$#uUD';

        return $route;
    }
1130551
public static function parseRoute($route)
    {
        if (!empty($route)) {
            $url = [];
            $r = explode('&', $route);
            $url[0] = $r[0];
            unset($r[0]);
            foreach ($r as $part) {
                $part = explode('=', $part);
                $url[$part[0]] = isset($part[1]) ? $part[1] : '';
            }

            return $url;
        }

        return '#';
    }
1097716
protected function _validateRoute($route)
    {
        // Split on comma.
        $domains = explode(',', trim($route));

        foreach ($domains as $domain) {
            $domain = str_replace('@', '', trim($domain));
            if (!$this->_validateDomain($domain)) return false;
        }

        return $route;
    }
23195
private function getDomainRegex($route)
    {
        ReflectionHelper::invokePrivateMethod($route, 'compileRoute');
        $compiledRoute = ReflectionHelper::readPrivateProperty($route, 'compiled');

        return $compiledRoute->getHostRegex();
    }
975202
private static function determineStaticPrefix(Route $route, array $tokens): string
    {
        if (!$tokens) {
            return '';
        }

        if ('text' !== $tokens[0][0]) {
            return ($route->hasDefault($tokens[0][3]) || '/' === $tokens[0][1]) ? '' : $tokens[0][1];
        }

        $prefix = $tokens[0][1];

        if (isset($tokens[1][1]) && '/' !== $tokens[1][1] && false === $route->hasDefault($tokens[1][3])) {
            $prefix .= $tokens[1][1];
        }

        return $prefix;
    }
861046
private function getMethods(Route $route)
    {
        $methods = $route->getMethods();
        sort($methods);

        return implode('|', $methods) ?: 'ANY';
    }
1306461
protected function prepareRoutePattern($route): string
    {
        $pattern = str_replace('/', '\/', $route);

        foreach ($this->getParams() as $param => $type) {
            switch ($type) {
                case 'int':
                case 'integer':
                    $pattern = str_replace("{\$$param}", "(?P<$param>[0-9]+)", $pattern);
                    break;
                case 'float':
                    $pattern = str_replace("{\$$param}", "(?P<$param>[0-9.,]+)", $pattern);
                    break;
                case 'string':
                case 'module':
                case 'controller':
                    $pattern = str_replace(
                        "{\$$param}",
                        "(?P<$param>[a-zA-Z0-9-_.]+)",
                        $pattern
                    );
                    break;
            }
        }
        return '/^' . $pattern . '/i';
    }
31385
private function isPrefixedRoute($route, $routePrefix)
    {
        $regexp = '~^'. preg_quote($routePrefix) .'~';
        
        return preg_match($regexp, $this->getRouteParam($route, 'uri'));
    }
53855
public function getRouteName($route)
    {
        if (!$this->routePath) {
            // Grab route_prefix config first. If it's not set,
            // grab the resources, and replace `\` with `.`, and
            // transform it all to lowercase.
            $this->routePath = $this->getConfig('route_prefix')
                ?: str_replace('\\', '.', strtolower($this->getConfig('resources')));
        }
        return "{$this->routePath}.v{$this->current}" . str_after($route, $this->routePath);
    }
1034501
protected function addWhereClausesToRoute( $route )
	{
		$where = isset( $route->getAction()['where'] ) ? $route->getAction()['where'] : [];
		$route->where( array_merge( $this->patterns, $where ) );

		return $route;
	}
982434
public function getRoute($route = null)
    {
        $routes = $this->getConsole()->getRoutes($route);
        $l1 = 10; $l2 = 10; $l3 = 10;
        $list = "";
        foreach($routes as $route) {
            if($l1 < strlen($route[1])) {
                $l1 = strlen($route[1]);
            }
            if($l2 < strlen($route[0])) {
                $l2 = strlen($route[0]);
            }
            if($l3 < strlen($route[2])) {
                $l3 = strlen($route[2]);
            }
        }
        foreach($routes as $route) {
            $list .= 
"| $route[1]".str_repeat(' ',$l1-strlen($route[1]))." | $route[0]".str_repeat(' ',$l2-strlen($route[0]))." | $route[2]".str_repeat(' ',$l3-strlen($route[2]))." |
+".str_repeat('-',$l1+2)."+".str_repeat('-',$l2+2)."+".str_repeat('-',$l3+2)."+
";
        }
        $list = "
+".str_repeat('-',$l1+2)."+".str_repeat('-',$l2+2)."+".str_repeat('-',$l3+2)."+
| ".Colors::GREEN.Colors::BG_BLACK."URI".Colors::WHITE.Colors::BG_BLACK.str_repeat(' ',$l1-strlen('URI'))." | ".Colors::GREEN.Colors::BG_BLACK."Method".Colors::WHITE.Colors::BG_BLACK.str_repeat(' ',$l2-strlen('Method'))." | ".Colors::GREEN.Colors::BG_BLACK."Action".Colors::WHITE.Colors::BG_BLACK.str_repeat(' ',$l3-strlen('Action'))." |
+".str_repeat('-',$l1+2)."+".str_repeat('-',$l2+2)."+".str_repeat('-',$l3+2)."+
".$list;
        return $list;
    }
712107
private function routeMatch(string $routeRegex, string $route)
    {
        $matches = [];
        if (preg_match($routeRegex, $route, $matches)) {
            unset($matches[0]);

            return array_values($matches);
        }

        return false;
    }
651452
public function matchPath($regexp)
	{
		if (substr($regexp, 0, 1) == '@') {
			$this->route_name = substr($regexp, 1);
		} else {
			parent::matchPath($regexp);
		}
	}
1344458
private function parseRoute($route)
    {
        if (is_string($route) || is_numeric($route) || $route instanceof UriInterface) {
            $route = array_merge(
                $this->defaultRedirect,
                [ 'route' => $route ]
            );
        } else {
            if (!is_array($route)) {
                throw new InvalidArgumentException(
                    'The new path must be a string (%s) or an array structure; received %s',
                    'URI, \Psr\Http\Message\UriInterface, or the name of a \Slim\Route',
                    (is_object($route) ? get_class($route) : gettype($route))
                );
            }

            if (!isset($route['status'])) {
                $route['status'] = $this->defaultRedirect['status'];
            }

            if (!isset($route['route_type'])) {
                $route['route_type'] = null;
            }

            if (!isset($route['data_key'])) {
                $route['data_key'] = null;
            }

            if (isset($route['template_route'])) {
                $route['route']         = $route['template_route'];
                $route['methods']       = [ 'GET' ];
                $route['data_key']      = 'template_data';
                $route['route_type']    = 'templates';
                $route['template_data'] = [];
                unset($route['template_route']);
            } elseif (isset($route['action_route'])) {
                $route['route']       = $route['action_route'];
                $route['methods']     = [ 'POST' ];
                $route['data_key']    = 'action_data';
                $route['route_type']  = 'actions';
                $route['action_data'] = [];
                unset($route['action_route']);
            } elseif (isset($route['script_route'])) {
                $route['route']       = $route['script_route'];
                $route['methods']     = [ 'GET' ];
                $route['data_key']    = 'script_data';
                $route['route_type']  = 'scripts';
                $route['script_data'] = [];
                unset($route['script_route']);
            } else {
                if (isset($route['route_type'])) {
                    switch ($route['route_type']) {
                        case 'templates':
                            $route['data_key'] = 'template_data';
                            $route['methods']  = [ 'GET' ];
                            break;

                        case 'actions':
                            $route['data_key'] = 'action_data';
                            $route['methods']  = [ 'POST' ];
                            break;

                        case 'scripts':
                            $route['data_key'] = 'script_data';
                            $route['methods']  = [ 'GET' ];
                            break;

                        case 'template':
                        case 'action':
                        case 'script':
                            $route['data_key']    = $route['route_type'] . '_data';
                            $route['route_type'] .= 's';
                            $route['methods'] = ($route['route_type'] === 'actions') ? [ 'POST' ] : [ 'GET' ];
                            break;

                        default:
                            $route['data_key']   = null;
                            $route['route_type'] = null;
                    }
                }

                if (!isset($route[$route['data_key']])) {
                    $route[$route['data_key']] = [];
                }
            }

            $found = false;
            if ($route['route_type'] && isset($route['route'])) {
                $container = $this->app()->getContainer();
                $routeName = $route['route'];
                $routeType = $route['route_type'];
                $appRoutes = $container['config']['routes'];

                if (isset($appRoutes[$routeType])) {
                    $appRoutes = $appRoutes[$routeType];

                    if (isset($appRoutes[$routeName])) {
                        $route = array_merge($route, $appRoutes[$routeName]);
                        $found = true;
                    } else {
                        foreach ($appRoutes as $targetRoute) {
                            if (isset($targetRoute['ident']) && $targetRoute['ident'] === $routeName) {
                                $route = array_merge($route, $targetRoute);
                                $found = true;
                            }
                        }
                    }
                }
            }

            if ($found === false) {
                if (!isset($route['route'])) {
                    $route['route'] = $this->defaultRedirect['route'];
                }

                if (!isset($route['methods'])) {
                    $route['methods'] = $this->defaultRedirect['methods'];
                }
            }
        }

        return $route;
    }