tld.rb allows you to check wether a TLD (top level domain) is valid
or not where ‘to be valid’ means that the TLD is presently in use on
the Internet. I need to state this for two reasons:
-
There are TLDs (like GDR’s dd) that once were in use but no longer
are. -
RFC 2606 [ext] (and equivalently BCP 32) define some TLDs that are
valid but only for very special purposes.
I did write the library because I did notice that part of the SPAM I
receive can be identified because it is addressed to recipent
addresses with invalid TLDs. This is the reason why I did include the
RFC 2606 (BCP 32) addresses - see below: They are no valid recipent
addresses but may occur due to malconfigured mail software (MTA or
MUA).
The list of valid TLDs is not static so there will now and then be
updates of this library. If you don’t belive this: I did check the
list with ‘International E-mail Accessibility’ by Olivier M.J.
Crepin-Leblond. That was a good idea - my list incorrectly did
include ‘fx’ - France (European Territories).
CONSTANTS provided - their meanings should be obvious except for the
last two: These are identical and are array of four TLDs that are
reserved for local use, testing purposes and documentation namely
test, example, invalid, and localhost.
TLD::All
TLD::Country
TLD::NonCountry
TLD::NonCountryOld
TLD::NonCountryNew
TLD::BCP32
TLD::RFC2606
METHODS provided - the only method that needs explanation is
TLD::valid?: it does assume that elements of TLD::RFC2606 are not
valid.
TLD::valid?(tld)
TLD::isCountry?(tld)
TLD::isNonCountry?(tld)
TLD::isNonCountryOld?(tld)
TLD::isNonCountryNew?(tld)
TLD::isRFC2606?(tld)
TLD::isBCP32?(tld)
Available at
http://members.lycos.nl/jupp/linux/soft/ruby/tld.html
Question on TLD::valid?: Should I add a parameter that allows to
control wether elements of TLD::RFC2606 are valid and set it per
default to false?
Josef ‘Jupp’ Schugt http://jupp.tux.nu jupp(AT)gmx(DOT)de