]> gitweb.michael.orlitzky.com - haeredes.git/blob - src/DNS.hs
Get it working for NS records.
[haeredes.git] / src / DNS.hs
1 module DNS (
2 normalize
3 )
4 where
5
6 import qualified Data.ByteString.Char8 as BS (
7 append,
8 last,
9 map,
10 pack )
11 import Data.Char (toLower)
12 import Network.DNS.Types (Domain)
13
14 -- | Normalize the given name by lowercasing and appending a trailing
15 -- dot (the root) if necessary.
16 normalize :: Domain -> Domain
17 normalize = normalize_case . normalize_root
18
19
20 normalize_root :: Domain -> Domain
21 normalize_root d
22 | BS.last d == '.' = d
23 | otherwise = d `BS.append` trailing_dot
24 where
25 trailing_dot = BS.pack "."
26
27
28 normalize_case :: Domain -> Domain
29 normalize_case = BS.map toLower