8000 Fix URL validator failure with empty string · symfony/symfony@e0910d9 · GitHub
[go: up one dir, main page]

Skip to content

Commit e0910d9

Browse files
bocharsky-bwfabpot
authored andcommitted
Fix URL validator failure with empty string
1 parent 0f61859 commit e0910d9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Symfony/Component/Validator/Constraints/UrlValidator.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class UrlValidator extends ConstraintValidator
4141
*/
4242
public function validate($value, Constraint $constraint)
4343
{
44-
if (null === $value || '' === $value) {
44+
if (null === $value) {
4545
return;
4646
}
4747

@@ -50,6 +50,10 @@ public function validate($value, Constraint $constraint)
5050
}
5151

5252
$value = (string) $value;
53+
if ('' === $value) {
54+
return;
55+
}
56+
5357
$pattern = sprintf(static::PATTERN, implode('|', $constraint->protocols));
5458

5559
if (!preg_match($pattern, $value)) {

0 commit comments

Comments
 (0)
0