Why does the Symfony2 URL validator skip the TLD?

2019-08-18 06:31发布

So, I'm developing a simple URL shortener in Symfony2 - one of the things that is required is the input must be a valid URL.

So I've set everything up and it's being validated, but it doesn't validate the TLD! It will pass things through such as "A" as being a valid domain!

What's going on?

标签: php url symfony
1条回答
ら.Afraid
2楼-- · 2019-08-18 06:43

You do not only want to validate the TLD, but also if the TLD is within the public suffix list:

Also please see a related question for a list of libraries: Get the subdomain from a URL

查看更多
登录 后发表回答