RFC: code to determine proper TLD for a given hostname

Dawit A. adawit at kde.org
Tue May 14 05:35:57 BST 2002


Hi,

We need code to properly determine the top most TLD of a given URL in 
several places: cookies, SSL certificate management, per-domain 
configuration dialogs like the cookie policy and user-agent settings
as well as Java/Javascript configurations.  Writing such code however 
is not as easy as it seems because the sheer number of variations and 
gottcha's involved.  Anwyays, this is my attempt to take a crack at doing 
just that.  The attached self-contained code is intended to find the top most 
domain value given a proper fully qualified hostname.  

Please test it to see if you get the results you expect and send me feedback.
For those that need it, here is how you compile the program:

g++ -I<qt-include-dir> -L<qt-lib-dir> -lqt-mt tld-test.cpp -o tld-test

where
<qt-include-dir>: the directory where the qt header files are located.
<qt-lib-dir>: the directory where the qt library is located.
"qt-mt" can be just "qt" in the unlikely case you compiled qt-3.x without 
thread support or are still on KDE 2.x and hence qt-2.x..

Known Issues:
===========

* <host>.<domain>.<country-code>, ex: foo.bar.ca might not be resolved 
correctly partially because I am unsure if such URLs can or do exist.

* Need to place the known highest TLD names in a separate file in order to 
allow easier management of them, i.e. no recompilation should be necessary 
just to add or remove the highest TLD names.

Appreciate any feedback....

Regards,
Dawit A.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tld-test.cpp
Type: text/x-c++src
Size: 2413 bytes
Desc: not available
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20020514/50ae4f73/attachment.cpp>


More information about the kfm-devel mailing list