{-# LANGUAGE CPP #-}
module Network.Wai.Util
( dropWhileEnd
, splitCommas
, trimWS
) where
import qualified Data.ByteString as S
import Data.Word8 (Word8, _comma, _space)
splitCommas :: S.ByteString -> [S.ByteString]
splitCommas :: ByteString -> [ByteString]
splitCommas = forall a b. (a -> b) -> [a] -> [b]
map ByteString -> ByteString
trimWS forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word8 -> ByteString -> [ByteString]
S.split Word8
_comma
trimWS :: S.ByteString -> S.ByteString
trimWS :: ByteString -> ByteString
trimWS = (Word8 -> Bool) -> ByteString -> ByteString
dropWhileEnd (forall a. Eq a => a -> a -> Bool
== Word8
_space) forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word8 -> Bool) -> ByteString -> ByteString
S.dropWhile (forall a. Eq a => a -> a -> Bool
== Word8
_space)
dropWhileEnd :: (Word8 -> Bool) -> S.ByteString -> S.ByteString
#if MIN_VERSION_bytestring(0,10,12)
dropWhileEnd :: (Word8 -> Bool) -> ByteString -> ByteString
dropWhileEnd = (Word8 -> Bool) -> ByteString -> ByteString
S.dropWhileEnd
#else
dropWhileEnd p = fst . S.spanEnd p
#endif