YoastSEO_Vendor\GuzzleHttp\Cookie
SetCookie::matchesPath() public Yoast 1.0
Check if the cookie matches a path value.
A request-path path-matches a given cookie-path if at least one of the following conditions holds:
- The cookie-path and the request-path are identical.
- The cookie-path is a prefix of the request-path, and the last character of the cookie-path is %x2F ("/").
- The cookie-path is a prefix of the request-path, and the first character of the request-path that is not included in the cookie- path is a %x2F ("/") character.
{} Это метод класса: SetCookie{}
Хуков нет.
Возвращает
true/false.
Использование
$SetCookie = new SetCookie(); $SetCookie->matchesPath( $requestPath );
- $requestPath(строка) (обязательный)
- Path to check against
Код SetCookie::matchesPath() SetCookie::matchesPath Yoast 15.6.2
public function matchesPath($requestPath)
{
$cookiePath = $this->getPath();
// Match on exact matches or when path is the default empty "/"
if ($cookiePath === '/' || $cookiePath == $requestPath) {
return \true;
}
// Ensure that the cookie-path is a prefix of the request path.
if (0 !== \strpos($requestPath, $cookiePath)) {
return \false;
}
// Match if the last character of the cookie-path is "/"
if (\substr($cookiePath, -1, 1) === '/') {
return \true;
}
// Match if the first character not included in cookie path is "/"
return \substr($requestPath, \strlen($cookiePath), 1) === '/';
}