Skip to content

Commit 396a366

Browse files
committed
Fix URL validator failure with empty string
1 parent 967c0e4 commit 396a366

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
@@ -48,7 +48,7 @@ public function validate($value, Constraint $constraint)
4848
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Url');
4949
}
5050

51-
if (null === $value || '' === $value) {
51+
if (null === $value) {
5252
return;
5353
}
5454

@@ -57,6 +57,10 @@ public function validate($value, Constraint $constraint)
5757
}
5858

5959
$value = (string) $value;
60+
if ('' === $value) {
61+
return;
62+
}
63+
6064
$pattern = sprintf(static::PATTERN, implode('|', $constraint->protocols));
6165

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

0 commit comments

Comments
 (0)