1234567891011121314151617181920212223 |
- module Data.SMTP.Parser.Host (scanHostName, parseHostName) where
- import Data.SMTP.Types.Account
- import Data.Attoparsec.ByteString.Char8
- import qualified Data.Attoparsec.ByteString.Char8 as A
- import Data.ByteString (ByteString)
- import qualified Data.Char as C
- parseHostName :: Parser HostName
- parseHostName = do
- h <- scanHostName
- return . HostName $ h
- scanHostName :: Parser ByteString
- scanHostName = A.takeWhile isHostChar
- isHostChar :: Char -> Bool
- isHostChar c
- | c `elem` ("._-" :: String) = True
- | C.isSpace c = False
- | C.isAlphaNum c = True
- | otherwise = False
|