Merge pull request #11297 from appwrite/fix/origin-validator-type-error

fix: Fix TypeError in Origin validator when array is passed
This commit is contained in:
Chirag Aggarwal
2026-02-11 18:20:32 +05:30
committed by GitHub
2 changed files with 6 additions and 4 deletions
+4 -4
View File
@@ -51,14 +51,14 @@ class Origin extends Validator
*/
public function isValid($origin): bool
{
$this->origin = $origin;
$this->scheme = null;
$this->host = null;
if (!is_string($origin) || empty($origin)) {
return false;
}
$this->origin = $origin;
$this->scheme = null;
$this->host = null;
$this->scheme = $this->parseScheme($origin);
$this->host = strtolower(parse_url($origin, PHP_URL_HOST) ?? '');
@@ -16,6 +16,8 @@ class OriginTest extends TestCase
$this->assertEquals(false, $validator->isValid(''));
$this->assertEquals(false, $validator->isValid('/'));
$this->assertEquals(false, $validator->isValid([]));
$this->assertEquals(false, $validator->isValid(['http://localhost']));
$this->assertEquals(true, $validator->isValid('https://localhost'));
$this->assertEquals(true, $validator->isValid('http://localhost'));