Fixes URL validator to accept single part urls
This commit is contained in:
parent
c778b030a9
commit
91e226e06e
@ -25,7 +25,7 @@ class UrlValidator extends ConstraintValidator
|
|||||||
const PATTERN = '~^
|
const PATTERN = '~^
|
||||||
(%s):// # protocol
|
(%s):// # protocol
|
||||||
(
|
(
|
||||||
([\pL\pN\pS-]+\.)+([\pL]|xn\-\-[\pL\pN-]+)+ # a domain name
|
([\pL\pN\pS-\.])+(\.?([\pL]|xn\-\-[\pL\pN-]+)+\.?) # a domain name
|
||||||
| # or
|
| # or
|
||||||
\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} # a IP address
|
\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} # a IP address
|
||||||
| # or
|
| # or
|
||||||
|
@ -72,6 +72,7 @@ class UrlValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
return array(
|
return array(
|
||||||
array('http://a.pl'),
|
array('http://a.pl'),
|
||||||
array('http://www.google.com'),
|
array('http://www.google.com'),
|
||||||
|
array('http://www.google.com.'),
|
||||||
array('http://www.google.museum'),
|
array('http://www.google.museum'),
|
||||||
array('https://google.com/'),
|
array('https://google.com/'),
|
||||||
array('https://google.com:80/'),
|
array('https://google.com:80/'),
|
||||||
@ -85,6 +86,7 @@ class UrlValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
array('http://symfony.com/#?'),
|
array('http://symfony.com/#?'),
|
||||||
array('http://www.symfony.com/doc/current/book/validation.html#supported-constraints'),
|
array('http://www.symfony.com/doc/current/book/validation.html#supported-constraints'),
|
||||||
array('http://very.long.domain.name.com/'),
|
array('http://very.long.domain.name.com/'),
|
||||||
|
array('http://localhost/'),
|
||||||
array('http://127.0.0.1/'),
|
array('http://127.0.0.1/'),
|
||||||
array('http://127.0.0.1:80/'),
|
array('http://127.0.0.1:80/'),
|
||||||
array('http://[::1]/'),
|
array('http://[::1]/'),
|
||||||
@ -152,6 +154,7 @@ class UrlValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
array('http://127.0.0.1:aa/'),
|
array('http://127.0.0.1:aa/'),
|
||||||
array('ftp://[::1]/'),
|
array('ftp://[::1]/'),
|
||||||
array('http://[::1'),
|
array('http://[::1'),
|
||||||
|
array('http://hello.☎/'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user