publicsuffixlist-0.1: Is a given string a domain suffix?

Safe HaskellNone




effectiveTLDPlusOne :: Text -> Maybe TextSource

>>> effectiveTLDPlusOne = effectiveTLDPlusOne' Network.PublicSuffixList.DataStructure.dataStructure

effectiveTLDPlusOne' :: DataStructure -> Text -> Maybe TextSource

This function returns whether or not this domain is owned by a registrar or a regular person. Nothing means that this is a registrar domain; 'Just x' means it's owned by a person. This is used to determine if a cookie is allowed to bet set for a particular domain. For example, you shouldn't be able to set a cookie for "com".

If the value is 'Just x', then the x value is what is known as the effective TLD plus one. This is one segment more than the suffix of the domain. For example, the eTLD+1 for is Just

Note that this function expects lowercase ASCII strings. These strings should be gotten from the toASCII algorithm as described in RFC 3490. These strings should not start or end with the '.' character, and should not have two '.' characters next to each other. (The toASCII algorithm is implemented in the 'idna' hackage package, though that package doesn't always map strings to lowercase)

isSuffix :: Text -> BoolSource

>>> isSuffix = isSuffix' Network.PublicSuffixList.DataStructure.dataStructure

isSuffix' :: DataStructure -> Text -> BoolSource

>>> isSuffix' dataStructure = isNothing . effectiveTLDPlusOne' dataStructure