module DNS ( normalize ) where import qualified Data.ByteString.Char8 as BS ( append, last, map, pack ) import Data.Char (toLower) import Network.DNS.Types (Domain) -- | Normalize the given name by lowercasing and appending a trailing -- dot (the root) if necessary. normalize :: Domain -> Domain normalize = normalize_case . normalize_root normalize_root :: Domain -> Domain normalize_root d | BS.last d == '.' = d | otherwise = d `BS.append` trailing_dot where trailing_dot = BS.pack "." normalize_case :: Domain -> Domain normalize_case = BS.map toLower