Skip to content

Commit 1b57ec8

Browse files
committed
[Validator] Allow an empty path in a URL with only a fragment or a query
1 parent 9da5e4c commit 1b57ec8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

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 or a / with something
36+
(/?|/\S+|\?|\#) # a /, nothing, a / with something, a query or a fragment
3737
$~ixu';
3838

3939
/**

Tests/Constraints/UrlValidatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ public function getValidUrls()
111111
array('http://☎.com/'),
112112
array('http://username:[email protected]'),
113113
array('http://[email protected]'),
114+
array('http://symfony.com?'),
115+
array('http://symfony.com#'),
114116
);
115117
}
116118

@@ -140,8 +142,6 @@ public function getInvalidUrls()
140142
array('http://goog_le.com'),
141143
array('http://google.com::aa'),
142144
array('http://google.com:aa'),
143-
array('http://symfony.com?'),
144-
array('http://symfony.com#'),
145145
array('ftp://google.fr'),
146146
array('faked://google.fr'),
147147
array('http://127.0.0.1:aa/'),

0 commit comments

Comments
 (0)