getHostAndTLD(domain)
Last updated October 29, 2010
Version: 2 | Requires: ColdFusion 5 | Library: NetLib
Description:
Returns the Hostname and TLD from a FQDN.
Return Values:
Returns a struct with hostname and toplevel domain.
Example:
<cfdump var="#GetHostAndTLD(domain)#">
Returns a struct.
result.hostname: example
result.tld: co.uk
Parameters:
| Name | Description | Required |
|---|---|---|
| domain | Full Qualified Domain Name. | Yes |
Full UDF Source:
<cfscript>
/**
* Get the TLD and Hostname from FQDN.
* v2 by Ray - just added a var scope
*
* @param domain Full Qualified Domain Name. (Required)
* @return Returns a struct with hostname and toplevel domain.
* @author Patrick Heppler (p.heppler@fusionality.de)
* @version 2, October 29, 2010
*/
function getHostAndTLD(domain) {
var result=structnew();
if (len(domain) lte 0) return false;
result.hostname=listfirst(domain,".");
if(listlen(domain,".") gt 2){
result.tld=listgetat(domain,2,".")&"."&listgetat(domain,3,".");
}
else{
result.tld=listlast(domain,".");
}
return result;
}
</cfscript>
Search CFLib.org
Latest Additions
Dave Anderson added
iniToStruct
20 day(s) ago
Dave Anderson added
deDupeArray
20 day(s) ago
Richard added
dice
22 day(s) ago
Isaac Dealey added
getRelative
a while ago
Top Rated
backupDatabase
Rated 5.0, 22 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)
highlightAndCrop
Rated 5.0, 4 time(s)