Why does the Symfony2 URL validator skip the TLD?

2019-08-18 06:04发布

问题:

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?

回答1:

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

  • The Public Suffix List

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



标签: php url symfony