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

Safe Haskell | None
Language | Haskell98

Network.PublicSuffixList.Lookup

Synopsis

- effectiveTLDPlusOne :: Text -> Maybe Text
- effectiveTLDPlusOne' :: DataStructure -> Text -> Maybe Text
- isSuffix :: Text -> Bool
- isSuffix' :: DataStructure -> Text -> Bool

# Documentation

effectiveTLDPlusOne :: Text -> Maybe Text

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

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

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 "this.is.a.subdom.com" is Just "subdom.com"

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 -> Bool

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

isSuffix' :: DataStructure -> Text -> Bool

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