Match the parameters in the URL
@param String $url
@param bool $strict Strict routing
@param bool $case Case sensitive
@return bool

@throws RouterException
484723
public function match(String $url, bool $strict, bool $case) {

		//If no strict routing, removing last / of $url if $this->path does not have it
		if(!$strict && $this->path[strlen($this->path) - 1] != '/')
			$url = rtrim($url, '/');

		if($case) 	$case = '';
		else 		$case = 'i';

		//Parameters name
		preg_match_all('/{([\w]+)}/', $this->path, $params);
		$params = $params['1'];

		//Replace default regex and brackets
		$path = preg_replace('/{([\w]+)}/', '([^/{}]+)', $this->path);
		$path = str_replace('\{', '{', $path);
		$path = str_replace('\}', '}', $path);

		//Add the regex if needed (regex array and params array not empty)
		$areRegex = !empty($this->regex) || !empty($params);
		if($areRegex) {
			//Explode the path
			$arrayPath = explode('([^/{}]+)', $path);
			$c = count($arrayPath);
			$path = '';

			//Between each '([^/{}]+)' add the path and the regex
			for($i = 0; $i<$c; $i++) {
				$path .= $arrayPath[$i];

				//The end of the path exploded is ""
				if($c-1 != $i) {
					if(isset($this->regex[$i]))
						$path .= $this->preg($this->regex[$i]);
					elseif(empty($this->regex))
						$path .= '([^/{}]+)';
					else
						$path .= $this->preg($this->regex[0]);
				}
			}
		}

		//Create global regex to match url
		$reg = "#^$path$#$case";

		if(!preg_match($reg, $url, $matches))
			return false;

		//Create an array with the parameters name and the value
		$slugs = array();
		if($areRegex) {
			array_shift($matches);
			$c = count($params);

			for($i = 0; $i<$c; $i++) {
				$slugs[$params[$i]] = $matches[$i];
			}
		}

		$this->slugs = $slugs;

		return true;

	}
194468
public boolean matches(URL url) {
        boolean matches = false;
        if(wildcardMatches(protocol, url.getProtocol()) && wildcardMatches(host, url.getHost()) && wildcardMatches(getPath(), url.getPath())) {
            matches = true;
        }
        return matches;
    }
1092803
function reroute($url=NULL,$permanent=FALSE,$die=TRUE) {
		if (!$url)
			$url=$this->hive['REALM'];
		if (is_array($url))
			$url=call_user_func_array([$this,'alias'],$url);
		elseif (preg_match('/^(?:@?([^\/()?]+)(?:(\(.+?)\))*(\?.+)*)/',
			$url,$parts) &&
			isset($this->hive['ALIASES'][$parts[1]]))
			$url=$this->hive['ALIASES'][$parts[1]];
		$url=$this->build($url,isset($parts[2])?$this->parse($parts[2]):[]).
			(isset($parts[3])?$parts[3]:'');
		if (($handler=$this->hive['ONREROUTE']) &&
			$this->call($handler,[$url,$permanent,$die])!==FALSE)
			return;
		if ($url[0]!='/' && !preg_match('/^\w+:\/\//i',$url))
			$url='/'.$url;
		if ($url[0]=='/' && (empty($url[1]) || $url[1]!='/')) {
			$port=$this->hive['PORT'];
			$port=in_array($port,[80,443])?'':(':'.$port);
			$url=$this->hive['SCHEME'].'://'.
				$this->hive['HOST'].$port.$this->hive['BASE'].$url;
		}
		if ($this->hive['CLI'])
			$this->mock('GET '.$url.' [cli]');
		else {
			header('Location: '.$url);
			$this->status($permanent?301:302);
			if ($die)
				die;
		}
	}
811819
public Map<Route, Double> matchRoutes(String url) {
        Map<Route, Double> routeMap = new HashMap<>();

        if (hashRoute.containsKey(url)) {
            hashRoute.get(url).forEach(hashR -> routeMap.put(new Route(hashR, null), 1.5));
        }

        for (RegexRoute route : regexRoute) {
            Matcher matcher = route.getPattern().matcher(url);
            if (matcher.matches()) {
                routeMap.put(new Route(route, matcher), 1.0);
            }
        }
        return routeMap;
    }
1028745
protected function _getUrl($url, $rel = false)
    {
        if (!is_array($url)) {
            $url = ltrim($url, '/');
            $url = '/' . $url;
        }
        if ($rel !== false) {
            $url = Router::url($url);
        }
        return $url;
    }
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;
                }
            }
        }
    }
615145
public Route matchRoute(String url) {
        if (hashRoute.containsKey(url)) {
            return new Route(hashRoute.get(url).get(0), null);
        }

        for (RegexRoute route : regexRoute) {
            Matcher matcher = route.getPattern().matcher(url);
            if (matcher.matches()) {
                return new Route(route, matcher);
            }
        }
        return null;
    }
608795
public function match(Parser $parser, $uri, $params = array(), $strict = false)
    {
        // match literal string from start to end
        $length = strlen($this->token);
        if (substr($uri, 0, $length) === $this->token) {
            $uri = substr($uri, $length);
        }

        // when there's no match, just return null if strict mode is given
        else if ($strict) {
            return null;
        }

        return array($uri, $params);
    }
1265257
public function matches($selector, $strict = false)
    {
        if (!is_string($selector)) {
            throw new InvalidArgumentException(sprintf('%s expects parameter 1 to be string, %s given', __METHOD__, gettype($selector)));
        }

        if (!$this->node instanceof DOMElement) {
            return false;
        }

        if ($selector === '*') {
            return true;
        }

        if (!$strict) {
            $innerHtml = $this->html();
            $html = "<root>$innerHtml</root>";

            $selector = 'root > ' . trim($selector);

            $document = new Document();

            $document->loadHtml($html, LIBXML_HTML_NODEFDTD | LIBXML_HTML_NOIMPLIED);

            return $document->has($selector);
        }

        $segments = Query::getSegments($selector);

        if (!array_key_exists('tag', $segments)) {
            throw new RuntimeException(sprintf('Tag name must be specified in %s', $selector));
        }

        if ($segments['tag'] !== $this->tag && $segments['tag'] !== '*') {
            return false;
        }

        $segments['id'] = array_key_exists('id', $segments) ? $segments['id'] : null;

        if ($segments['id'] !== $this->getAttribute('id')) {
            return false;
        }

        $classes = $this->hasAttribute('class') ? explode(' ', trim($this->getAttribute('class'))) : [];

        $segments['classes'] = array_key_exists('classes', $segments) ? $segments['classes'] : [];

        $diff1 = array_diff($segments['classes'], $classes);
        $diff2 = array_diff($classes, $segments['classes']);

        if (count($diff1) > 0 || count($diff2) > 0) {
            return false;
        }

        $attributes = $this->attributes();

        unset($attributes['id'], $attributes['class']);

        $segments['attributes'] = array_key_exists('attributes', $segments) ? $segments['attributes'] : [];

        $diff1 = array_diff_assoc($segments['attributes'], $attributes);
        $diff2 = array_diff_assoc($attributes, $segments['attributes']);

        // if the attributes are not equal
        if (count($diff1) > 0 || count($diff2) > 0) {
            return false;
        }

        return true;
    }
94362
def match_url(self, url, options=None):
        
        options = options or {}
        for optname in self.options:
            if optname == 'match-case':  # TODO
                continue

            if optname not in options:
                raise ValueError("Rule requires option %s" % optname)

            if optname == 'domain':
                if not self._domain_matches(options['domain']):
                    return False
                continue

            if options[optname] != self.options[optname]:
                return False

        return self._url_matches(url)
299492
public static function isUrl($url, bool $schemeRequired = true) {
		try {
			$url = Url::create($url)->toIdnaAsciiString();
		} catch (\InvalidArgumentException $e) {
			return false;
		}
		
		if ($schemeRequired) {
			if (false !== filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED)) {
				return true;
			}
		} else {
			if (false !== filter_var($url, FILTER_VALIDATE_URL)) {
				return true;
			}
		}
		
		return false;
	}
736169
public function match(UrlObject $url)
    {
        $pathWithHost = $this->str($url->getHost() . $url->getPath())->trimRight('/')->val();
        $pathWithoutHost = $this->str($url->getPath())->trimRight('/')->val();

        /**
         * @var Route $route
         */
        foreach (Router::getRouteCollection()->all() as $name => $route) {
            $compiledRoute = $route->compile();

            // 1. Make sure staticPrefix and path both contain leading slash
            $staticPrefix = $compiledRoute->getStaticPrefix();
            $staticPrefix = $staticPrefix != '' && !$this->str($staticPrefix)->startsWith('/'
            ) ? '/' . $staticPrefix : $staticPrefix;
            $urlPath = $this->str($url->getPath())->startsWith('/') ? $url->getPath() : '/' . $url->getPath();

            // 2. First check the static prefix on path because we don't want to use heavy preg_matching if the prefix doesn't match
            if ($staticPrefix != '' && strpos($urlPath, $staticPrefix) !== 0) {
                continue;
            }

            // let's check the host
            if ($route->getHost() != '' && $route->getHost() != $url->getHost()) {
                continue;
            }

            // let's check schemes
            if (count($route->getSchemes()) > 0 && !in_array($url->getScheme(), $route->getSchemes())) {
                continue;
            }

            // let's check them methods
            if (count($route->getMethods()) > 0 && !in_array($this->request()->server()->requestMethod(),
                                                             $route->getMethods()
                )
            ) {
                continue;
            }

            // check if we need to match the host also
            if ($route->getHost() != '') {
                $fullPath = $pathWithHost;
            } else {
                $fullPath = $pathWithoutHost;
            }

            // 3. Check the root path
            if ($route->getPath() == '' && ($url->getPath() != '/' && $url->getPath() != '')) {
                continue;
            }

            if (!$compiledRoute->getRegex()) {
                if ($fullPath != '') {
                    continue;
                }

                // if there is no regex, that means we can only match an empty path
                $params = [];
            } else {
                // finally let's try to match the full url
                preg_match_all($compiledRoute->getRegex(), $fullPath, $matches);

                if (count($matches[0]) < 1) {

                    // if we haven't matched the url, lets see if we have all the default values for every pattern,
                    // because if we do, and since the static prefix has been matched, we can still consider the url to be
                    // matched
                    if ($compiledRoute->getDefaultRoute()) {
                        preg_match_all($compiledRoute->getRegex(), $compiledRoute->getDefaultRoute(), $matches);
                        if (count($matches[0]) < 1) {
                            continue;
                        }
                    } else {
                        continue;
                    }
                }

                // if we matched the route, we need to extract the parameters
                $params = $this->extractParameters($matches, $compiledRoute);
            }

            return new MatchedRoute($route, $params);
        }

        return false;
    }
1008756
public function parse($url)
    {
        foreach ($this->map as $pattern) {
            $pattern = $this->compile($pattern);
            if (preg_match($pattern, $url, $match)) {
                // remove numeric keys
                foreach ($match as $key => $value) {
                    if (is_numeric($key)) {
                        unset($match[$key]);
                    }
                }

                return $match;
            }
        }

        throw new Exceptions\InvalidArgumentException("URL '$url' did not match any route.");
    }
997231
private function checkRouteAlias($url)
    {
        $alias = strpos($url, '|') ? strstr($url, '|', true) : $url;

        $item = $this->router->getAlias($alias);

        return $item ? $item->check($url) : false;
    }
430641
public static function clean_uri($uri, $strict = false)
	{
		$filters = \Config::get('security.uri_filter', array());
		$filters = is_array($filters) ? $filters : array($filters);

		$strict and $uri = preg_replace(array("/\.+\//", '/\/+/'), '/', $uri);

		return static::clean($uri, $filters);
	}
585799
public function match($url, $to = null, array $params = array())
    {
        if (!$params && is_array($to)) {
            $params = $to;
            $to = null;
        }
        $this->createAndAddRoute($url, $to, $params);
    }
171208
protected function doRouteMatching($url)
    {
        $matches = array();
        foreach ($this->route_definitions as $name => $route) {
            if (preg_match($route['regex'], $url, $matches)) {
                $matches[0] = $name;
                return $matches;
            }
        }
        return false;
    }