Host.hs 582 B

1234567891011121314151617181920212223
  1. module Data.SMTP.Parser.Host (scanHostName, parseHostName) where
  2. import Data.SMTP.Types.Account
  3. import Data.Attoparsec.ByteString.Char8
  4. import qualified Data.Attoparsec.ByteString.Char8 as A
  5. import Data.ByteString (ByteString)
  6. import qualified Data.Char as C
  7. parseHostName :: Parser HostName
  8. parseHostName = do
  9. h <- scanHostName
  10. return . HostName $ h
  11. scanHostName :: Parser ByteString
  12. scanHostName = A.takeWhile isHostChar
  13. isHostChar :: Char -> Bool
  14. isHostChar c
  15. | c `elem` ("._-" :: String) = True
  16. | C.isSpace c = False
  17. | C.isAlphaNum c = True
  18. | otherwise = False