[Validator] Allow an empty path with a non empty fragment or a query

This commit is contained in:
Jakub Zalas 2015-11-13 07:29:58 +00:00
parent ec39f9da5d
commit 2d0af8e719
2 changed files with 5 additions and 1 deletions

View File

@ -33,7 +33,7 @@ class UrlValidator extends ConstraintValidator
\] # a IPv6 address \] # a IPv6 address
) )
(:[0-9]+)? # a port (optional) (:[0-9]+)? # a port (optional)
(/?|/\S+|\?|\#) # a /, nothing, a / with something, a query or a fragment (/?|/\S+|\?\S*|\#\S*) # a /, nothing, a / with something, a query or a fragment
$~ixu'; $~ixu';
/** /**

View File

@ -112,7 +112,11 @@ class UrlValidatorTest extends AbstractConstraintValidatorTest
array('http://username:password@symfony.com'), array('http://username:password@symfony.com'),
array('http://user-name@symfony.com'), array('http://user-name@symfony.com'),
array('http://symfony.com?'), array('http://symfony.com?'),
array('http://symfony.com?query=1'),
array('http://symfony.com/?query=1'),
array('http://symfony.com#'), array('http://symfony.com#'),
array('http://symfony.com#fragment'),
array('http://symfony.com/#fragment'),
); );
} }