Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2d0af8e

Browse files
committed
[Validator] Allow an empty path with a non empty fragment or a query
1 parent ec39f9d commit 2d0af8e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class UrlValidator extends ConstraintValidator
3333
\] # a IPv6 address
3434
)
3535
(:[0-9]+)? # a port (optional)
36-
(/?|/\S+|\?|\#) # a /, nothing, a / with something, a query or a fragment
36+
(/?|/\S+|\?\S*|\#\S*) # a /, nothing, a / with something, a query or a fragment
3737
$~ixu';
3838

3939
/**

src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,11 @@ public function getValidUrls()
112112
array('http://username:[email protected]'),
113113
array('http://[email protected]'),
114114
array('http://symfony.com?'),
115+
array('http://symfony.com?query=1'),
116+
array('http://symfony.com/?query=1'),
115117
array('http://symfony.com#'),
118+
array('http://symfony.com#fragment'),
119+
array('http://symfony.com/#fragment'),
116120
);
117121
}
118122

0 commit comments

Comments
 (0)