YoastSEO_Vendor\GuzzleHttp
is_host_in_noproxy() Yoast 1.0
Returns true if the provided host matches any of the no proxy areas.
This method will strip a port from the host if it is present. Each pattern can be matched with an exact match (e.g., "foo.com" == "foo.com") or a partial match: (e.g., "foo.com" == "baz.foo.com" and ".foo.com" == "baz.foo.com", but ".foo.com" != "foo.com").
Areas are matched in the following cases:
- "*" (without quotes) always matches any hosts.
- An exact match.
- The area starts with "." and the area is the last part of the host. e.g.
'.mit.edu' will match any host that ends with '.mit.edu'.
Хуков нет.
Возвращает
true/false.
Использование
is_host_in_noproxy( $host, $noProxyArray );
- $host(строка) (обязательный)
- Host to check against the patterns.
- $noProxyArray(массив) (обязательный)
- An array of host patterns.
Код is_host_in_noproxy() is host in noproxy Yoast 15.6.2
function is_host_in_noproxy($host, array $noProxyArray)
{
if (\strlen($host) === 0) {
throw new \InvalidArgumentException('Empty host provided');
}
// Strip port if present.
if (\strpos($host, ':')) {
$host = \explode($host, ':', 2)[0];
}
foreach ($noProxyArray as $area) {
// Always match on wildcards.
if ($area === '*') {
return \true;
} elseif (empty($area)) {
// Don't match on empty values.
continue;
} elseif ($area === $host) {
// Exact matches.
return \true;
} else {
// Special match if the area when prefixed with ".". Remove any
// existing leading "." and add a new leading ".".
$area = '.' . \ltrim($area, '.');
if (\substr($host, -\strlen($area)) === $area) {
return \true;
}
}
}
return \false;
}