chore: update scheme check

This commit is contained in:
Chirag Aggarwal 2025-06-27 08:29:13 +05:30
parent 1555abcbd6
commit fffdab23f9

View file

@ -40,14 +40,16 @@ class Origin extends Validator
}
$this->scheme = $this->parseScheme($origin);
$this->host = strtolower(parse_url($origin, PHP_URL_HOST));
if (!empty($this->scheme) && !in_array($this->scheme, $this->schemes, true)) {
return false;
}
$this->host = strtolower(parse_url($origin, PHP_URL_HOST) ?? '');
$validator = new Hostname($this->hostnames);
return $validator->isValid($this->host);
if (in_array($this->scheme, ['http', 'https']) && $validator->isValid($this->host)) { // Valid HTTP/HTTPS origin
return true;
} if (!empty($this->scheme) && in_array($this->scheme, $this->schemes, true)) { // Valid scheme-based origin
return true;
}
return false;
}
/**