Match an URL against the patterns from strip-hosts

@return bool
775281
private function matchStripHostsPatterns($url)
    {
        if (Filesystem::isLocalPath($url)) {
            return true;
        }

        if (is_array($this->stripHosts)) {
            $url = trim(parse_url($url, PHP_URL_HOST), '[]');

            if (false !== filter_var($url, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
                $urltype = 'ipv4';
            } elseif (false !== filter_var($url, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
                $urltype = 'ipv6';
            } else {
                $urltype = 'name';
            }

            if ('ipv4' === $urltype || 'ipv6' === $urltype) {
                $urlunpack = unpack('N*', @inet_pton($url));
            }

            foreach ($this->stripHosts as $pattern) {
                @list($type, $host, $mask) = $pattern;

                if ('/local' === $type) {
                    if ('name' === $urltype && 'localhost' === strtolower($url)
                        || ('ipv4' === $urltype || 'ipv6' === $urltype)
                        && false === filter_var($url, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)
                    ) {
                        return true;
                    }
                } elseif ('/private' === $type) {
                    if (('ipv4' === $urltype || 'ipv6' === $urltype)
                        && false === filter_var($url, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)
                    ) {
                        return true;
                    }
                } elseif ('ipv4' === $type || 'ipv6' === $type) {
                    if ($urltype === $type && $this->matchAddr($urlunpack, $host, $mask)) {
                        return true;
                    }
                } elseif ('name' === $type) {
                    if ('name' === $urltype && preg_match($host, $url)) {
                        return true;
                    }
                }
            }
        }
    }
16907
public function matches($url)
    {
        $infos = parse_url($url);

        if ($this->expired()) {
            return false;
        }

        if (!$this->matchesScheme($infos['scheme'])) {
            return false;
        }

        if (!$this->matchesDomain($infos['host'])) {
            return false;
        }

        return $this->matchesPath($infos['path']);
    }
282488
def matches_pattern(self, other):
        """"""
        matches = False
        if hasattr(other, 'addr'):
            if self.addr is None or other.addr is None:
                matches = True
            else:
                matches = self.addr == other.addr
        return matches
518108
def any_match(self, urls):
        
        return any(urlparse(u).hostname in self for u in urls)
1053150
public function matches(string $pattern): bool
	{
		return (bool) preg_match('#' . $pattern . '#', $this->request->getPath());
	}
1186503
public function found_file_match($url)
    {
        if ($url[0] != '/' && $this->fileExists($this->root . $url)) {
            return array(true, $this->baseurl . $this->prefix . $this->base . $url);
        }

        return array(false, $url);
    }
1329581
public function isHost(string $host, bool $includeSubDomains = false) : bool
    {
        $thisHost = strtolower($this->host);
        $thatHost = strtolower($host);

        if (! $includeSubDomains) {
            return $thisHost === $thatHost;
        }

        $thisHost = explode('.', $thisHost);
        $thatHost = explode('.', $thatHost);

        return array_slice($thisHost, - count($thatHost)) === $thatHost;
    }
1353934
public function matches($url, $method)
    {
        if ($this->httpmethod !== 'ANY' && strtolower($method) !== strtolower($this->httpmethod)) {
            return false;
        }

        // Exact match OR pattern match
        return $this->pattern == $url || $this->patternMatch($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;
                }
            }
        }
    }
249184
protected function _matchRelative($url) {
        $relative = $this->_relative();
        if (!$relative) {
            return true;
        }
        $components = parse_url($url);
        if (!isset($components['host'])) {
            return true;
        }
        $path = trim($components['path'], '/');
        return strpos($path, $relative) === 0;
    }
140535
public function getMatchedRouteName()
    {
        if ($this->isFailure()) {
            return false;
        }
        if (! $this->matchedRouteName && $this->route) {
            $this->matchedRouteName = $this->route->getName();
        }

        return $this->matchedRouteName;
    }
1027491
protected function isUrlExcluded()
    {
        $excludedUrls = $this->getAttributes('exclude_unknown_urls', null);
        $siteUrls = $this->getAttributes('urls', null);

        if (!empty($excludedUrls) && !empty($siteUrls)) {
            $url = $this->request->getParam('url');
            $parsedUrl = parse_url($url);

            $trackingUrl = new SiteUrls();
            $urls = $trackingUrl->groupUrlsByHost(array($this->idSite => $siteUrls));

            $idSites = $trackingUrl->getIdSitesMatchingUrl($parsedUrl, $urls);
            $isUrlExcluded = !isset($idSites) || !in_array($this->idSite, $idSites);

            return $isUrlExcluded;
        }

        return false;
    }
1167776
protected function doesUrlMatchToAtLeastOnePattern($url, array $patterns)
    {
        foreach ($patterns as $pattern) {
            $regex = '|' . $pattern . '|';
            $this->verbose(
                "Checking url '" . $url . "' with regex '" . $regex . "' -> ",
                OutputInterface::VERBOSITY_VERBOSE
            );
            if (preg_match($regex, $url)) {
                $this->verbose("MATCHED\n", OutputInterface::VERBOSITY_VERBOSE);
                return true;
            } else {
                $this->verbose("NOT matched\n", OutputInterface::VERBOSITY_VERBOSE);
            }
        }
        return false;
    }
1142147
protected function _matchHost($url) {
        $components = parse_url($url);
        return !(isset($components['host']) && $components['host'] != $this->_hostname());
    }
1085804
protected function matchDirect()
    {
        // Create variable used to keep track on progress
        $endpoint = false;

        // check without a trailing slash
        if (isset($this->routes[$this->requestUri])) {
            $endpoint = $this->routes[$this->requestUri];
        } else {
            // no match return false
            return false;
        }

        // check if endpoint class exists
        if (!$this->endpointExists($endpoint)) {
            throw new NotFound();
        } elseif (!$this->endpointMethodExists($endpoint, $this->requestMethod)) {
            // route found but method can't be found
            throw new MethodNotAllowed();
        }

        // found a direct match, set needed properties
        $this->matchedRoute = $this->requestUri;
        $this->matchedEndpoint = $endpoint;
        $this->matchedMethod = $this->requestMethod;

        // we found our match, stop looking for more
        return true;
    }
437462
public function match()
    {
        // if forceSlash is ON, and there is no trailing slash on current request
        if ($this->forceSlash && !$this->hasTrailingSlash($this->uriRelative)) {
            $this->forceSlash();
        }
        // Find control for current request, first with exact matching, then with variable matching
        if ($this->matchExact() || $this->matchVariable()) {
            return $this->control; // Match found
        }

        return null; // No match found
    }
1239473
public function filterMatch($patterns)
    {
        $patterns = is_string($patterns) ? [$patterns] : $patterns;

        // String pattern is assumed to be path.
        foreach ($patterns as $key => $pattern) {
            if (is_string($pattern)) {
                $patterns[$key] = ['path' => $pattern];
            }
        }

        return $this->filter(function ($route) use ($patterns) {
            // If any of patterns matches - route passes.
            foreach ($patterns as $pattern) {
                if ($this->isRouteMatchesPattern($route, $pattern)) {
                    return true;
                }
            }

            // If all patterns don't match - route is filtered out.
            return false;
        });
    }