function NoProxyPattern::match
Returns true if the url is matched by a rule
1 call to NoProxyPattern::match()
- NoProxyPattern::test in vendor/
composer/ composer/ src/ Composer/ Util/ NoProxyPattern.php - Returns true if a URL matches the NO_PROXY pattern
File
-
vendor/
composer/ composer/ src/ Composer/ Util/ NoProxyPattern.php, line 106
Class
- NoProxyPattern
- Tests URLs against NO_PROXY patterns
Namespace
Composer\UtilCode
protected function match(int $index, string $hostName, stdClass $url) : bool {
if (!($rule = $this->getRule($index, $hostName))) {
// Data must have been misformatted
return false;
}
if ($rule->ipdata) {
// Match ipdata first
if (!$url->ipdata) {
return false;
}
if ($rule->ipdata->netmask) {
return $this->matchRange($rule->ipdata, $url->ipdata);
}
$match = $rule->ipdata->ip === $url->ipdata->ip;
}
else {
// Match host and port
$haystack = substr($url->name, -strlen($rule->name));
$match = stripos($haystack, $rule->name) === 0;
}
if ($match && $rule->port) {
$match = $rule->port === $url->port;
}
return $match;
}