Skip to content

Commit

Permalink
[Validator] Allow an empty path with a non empty fragment or a query
Browse files Browse the repository at this point in the history
  • Loading branch information
jakzal committed Nov 13, 2015
1 parent 65ad905 commit dbac482
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Constraints/UrlValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class UrlValidator extends ConstraintValidator
\] # a IPv6 address
)
(:[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';

/**
Expand Down
4 changes: 4 additions & 0 deletions Tests/Constraints/UrlValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ public function getValidUrls()
array('http://username:[email protected]'),
array('http://[email protected]'),
array('http://symfony.com?'),
array('http://symfony.com?query=1'),
array('http://symfony.com/?query=1'),
array('http://symfony.com#'),
array('http://symfony.com#fragment'),
array('http://symfony.com/#fragment'),
);
}

Expand Down

0 comments on commit dbac482

Please sign in to comment.