franckverrot / activevalidators

Collection of ActiveModel/ActiveRecord validators
https://rubygems.org/gems/activevalidators
MIT License
306 stars 49 forks source link

http://mywebsite. passes url validation #101

Closed krachtstefan closed 6 years ago

krachtstefan commented 6 years ago

I just noticed that http://mywebsite. passes url validation

franckverrot commented 6 years ago

Hi @krachtstefan, thanks for opening this issue.

I checked RFC 1034 (page 7) once again (haven't looked at it in years 😄) and it seems like this is correct:

Since a complete domain name ends with the root label, this leads to a printed form which ends in a dot. We use this property to distinguish between:

  • a character string which represents a complete domain name (often called "absolute"). For example, "poneria.ISI.EDU."

  • a character string that represents the starting labels of a domain name which is incomplete, and should be completed by local software using knowledge of the local domain (often called "relative"). For example, "poneria" used in the ISI.EDU domain.

You could try pinging google.com by doing ping google.com. and it should ping properly.

Tell me if that helps, and thanks again for reporting this!

krachtstefan commented 6 years ago

Hi @franckverrot, thanks for your quick reply. I must admit that I didn't look that up, so thanks for clarification :)

I would still think it would be a good option to support trailing dots for "real world examples".

Would you consider a PR with an optional parameter like { :allow_trailing_dot => true }

krachtstefan commented 6 years ago

This issue can stay closed btw. My PR from yesterday will accidentally fix this as well. With :require_tld => true a trailing dot will not pass validation.