Check if a route matches a given url

@param $requestUri
@return bool
516696
public function matches($requestUri)
    {
        $requestUri = $this->normalizeUri($requestUri);
        $regex = $this->compile();

        if (preg_match('#^'.$regex.'$#i', $requestUri, $out)) {
            $this->data = $this->getOnlyStringKeys($out);
            return true;
        }

        return false;
    }
1347449
protected boolean shouldIgnorePath(String requestUri) {
        for (String path : router.getIgnorePaths()) {
            if (requestUri.startsWith(path)) {
                return true;
            }
        }

        return false;
    }
939550
private function compareUris($redirect_uri, $clientRedirectUri)
    {
        if (!$redirect_uri || !$clientRedirectUri) {
            return false;
        }

        $wanted = array_fill_keys(['scheme', 'host', 'port', 'path'], true);

        // gets only scheme, host, port, path from uri
        $redirect_uri = array_intersect_key(parse_url($redirect_uri), $wanted);
        $clientRedirectUri = array_intersect_key(parse_url($clientRedirectUri), $wanted);

        return strcmp(implode($redirect_uri), implode($clientRedirectUri)) === 0;
    }
721090
public function match($url)
    {
        foreach ($this->routes as $route => $params) {
            if (preg_match($route, $url, $matches)) {
                //Check if given method is matched
                if ($this->methodMatch($params['method'], null, new Request())) {
                    // Get named capture group values
                    foreach ($matches as $key => $match) {
                        if (is_string($key)) {
                            $params[$key] = $match;
                        }
                    }
                    $this->params = $params;

                    return true;
                }
            }
        }
    }
941373
private function validateRequestURI(&$requestURI)
    {
        if ($requestURI != '/' && substr($requestURI, -1) == '/') {
            $url = rtrim($requestURI, '/');

            if (php_sapi_name() === 'cli') {
                exit("Please ensure the URL you typed in does not have a trailing backslash.\n");
            }

            header("Location: " . $url);
            exit();
        }
    }
408511
public function setRequestUri(string $requestUri) : Request
    {
        $pos = strpos($requestUri, '?');

        if ($pos === false) {
            $this->path = $requestUri;
            $this->queryString = '';
            $this->query = [];
        } else {
            $this->path        = substr($requestUri, 0, $pos);
            $this->queryString = substr($requestUri, $pos + 1);

            if ($this->queryString === '') {
                $this->query = [];
            } else {
                parse_str($this->queryString, $this->query);
            }
        }

        $this->requestUri = $requestUri;

        return $this;
    }
326895
public function isAllowed(RequestInterface $uri)
    {
        if (preg_match(sprintf('#^%s$#', $this->regexp), $uri->getUri()->getPath())) {
            if (isset($this->assertion)) {
                $assertion = $this->assertion;

                return $assertion();
            } else {
                return true;
            }
        }

        return true;
    }
1348265
public function findMatchingRoutes( string $uri ) : array
	{
		$matchedRoutes = [];

		foreach ( $this->getRoutes() as $route )
		{
			if ( $route->matches( $uri ) )
			{
				$matchedRoutes[] = $route;
			}
		}

		return $matchedRoutes;
	}
836956
protected function matchUrlDirectly($url)
    {
        foreach ($this->routes as $route) {
            if ($route->matchDirectly($url)) {
                return $route;
            }
        }
        return null;
    }
135690
public function matches(Route $route, Request $request)
    {
        return in_array($request->getMethod(), $route->methods());
    }
1130421
public function match($resourceUri)
    {
        $paramNames = $this->getParamNames();

        $pattern =  $this->getPattern();

        if (preg_match('/\[:options\]/', $pattern)) {
            $exp = explode('[:options]', $pattern);
            $estatico = $exp[0];
            $estaticoDinamico = explode($estatico, $resourceUri);
            if (count($estaticoDinamico) == 2) {
                $estaticoUrl = explode($estaticoDinamico[1], $resourceUri);
                $estaticoUrl = $estaticoUrl[0];

                if ($estaticoUrl == $estatico){
                    //estou em uma rota dinamica valida
                    $dinamico = $estaticoDinamico[1];
                    $this->options = explode('/', $dinamico);
                    return true;
                }
            } else {
                return false;
            }
        } else {
            $patternAsRegex = preg_replace_callback('@:[\w]+@', [$this, 'convertToRegex'], $this->pattern);
            if (substr($this->pattern, -1) === '/') {
                $patternAsRegex = $patternAsRegex . '?';
            }
            $patternAsRegex = '@^' . $patternAsRegex . '$@';

            if (preg_match($patternAsRegex, $resourceUri, $paramValues)) {
                array_shift($paramValues);
                
                if (count($paramValues) > 0) {
                    foreach ($paramNames as $index => $value) {
                        $this->params[substr($value, 1)] = urldecode($paramValues[$index]);
                    }
                }
                return true;
            } else {
                return false;
            }
        }
    }
1256717
protected function normalizeUri($requestUri)
    {
        $len = strlen($requestUri);

        if ($len == 0) {
            return '/';
        }

        if ($len == 1) {
            return $requestUri;
        }

        return trim($requestUri, '/');
    }
282560
private function uriMatchesPattern( $requestUrl, $pattern )
	{
		if ( $requestUrl == $pattern )
		{
			return true;
		}
		elseif ( @preg_match( $pattern, '' ) !== false )
		{
			return boolval( preg_match( $pattern, $requestUrl ) );
		}
		else
		{
			return false;
		}
	}
1050628
public function matches( Route $route, Request $request )
	{
		if ( $route->httpOnly() )
			return !$request->secure();
		elseif ( $route->secure() )
			return $request->secure();

		return true;
	}
37003
function match(RequestInterface $request)
    {
        if ($preReq = $this->getPreparator()) {
            $request = $preReq->withRequestOnMatch($request);

            if (! $request instanceof RequestInterface )
                throw new \RuntimeException(sprintf(
                    'Missing RequestInterface While Preparing Request Object Through (%s).'
                    , \Poirot\Std\flatten($preReq)
                ));
        }


        ## match against connected routers if exists
        if (empty($this->routesAdd))
            return false;

        # build queue list for routers to match:

        # match routes:
        $routeMatch = false;
        foreach($this->_priorityQueue() as $route) {
            /** @var iRoute $r */
            $r = $route;
            if ($routeMatch = $r->match($request)) break;
        }

        ## if route match merge stack default params with match route
        /** @var iRoute $routeMatch */
        if ($routeMatch) {
            # $routeMatch = clone $routeMatch; // this can be skipped because use of match on each route
            \Poirot\Router\mergeParamsIntoRouter($routeMatch, $this->params());
        }

        return $routeMatch;
    }
474308
public boolean matches(String requestUri) {
        Matcher matcher = regex.matcher(requestUri);
        return matcher.matches();
    }
723783
public function matchRequestPath($requestPath)
    {
        foreach ([$requestPath, urlencode($requestPath), urldecode($requestPath)] as $path) {
            foreach ([$this->catch_path, urlencode($this->catch_path), urldecode($this->catch_path)] as $catch) {
                if ($this->pathMatcher($path, $catch)) {
                    return true;
                }
            }
        }

        return false;
    }