Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Validator/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public function isValid($value): bool
return false;
}

if (strpos($value, '://') !== false) {
return false;
}

Comment thread
stnguyen90 marked this conversation as resolved.
Outdated
if (\filter_var($value, FILTER_VALIDATE_DOMAIN) === false) {
return false;
}
Expand Down
4 changes: 4 additions & 0 deletions tests/Validator/DomainTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Utopia PHP Framework
*
Expand Down Expand Up @@ -37,6 +38,9 @@ public function testIsValid()
$this->assertEquals(true, $this->domain->isValid('example.io'));
$this->assertEquals(true, $this->domain->isValid('example.org'));
$this->assertEquals(true, $this->domain->isValid('example.org'));
$this->assertEquals(false, $this->domain->isValid('http://example.com'));
$this->assertEquals(false, $this->domain->isValid('https://example.com'));
$this->assertEquals(false, $this->domain->isValid('ftp://example.com'));
$this->assertEquals(false, $this->domain->isValid(false));
$this->assertEquals(false, $this->domain->isValid('.'));
$this->assertEquals(false, $this->domain->isValid('..'));
Expand Down