Replace deprecated breakByte function.
This commit is contained in:
parent
a47ceec445
commit
04cb3730a0
@ -77,6 +77,7 @@ import Data.Text.Lazy.Builder (toLazyText)
|
|||||||
import Yesod.Core.Types
|
import Yesod.Core.Types
|
||||||
import Text.Lucius (Css, renderCss)
|
import Text.Lucius (Css, renderCss)
|
||||||
import Text.Julius (Javascript, unJavascript)
|
import Text.Julius (Javascript, unJavascript)
|
||||||
|
import Data.Word8 (_semicolon, _slash)
|
||||||
|
|
||||||
-- | Zero-length enumerator.
|
-- | Zero-length enumerator.
|
||||||
emptyContent :: Content
|
emptyContent :: Content
|
||||||
@ -225,18 +226,15 @@ typeOctet = "application/octet-stream"
|
|||||||
-- For example, \"text/html; charset=utf-8\" is commonly used to specify the
|
-- For example, \"text/html; charset=utf-8\" is commonly used to specify the
|
||||||
-- character encoding for HTML data. This function would return \"text/html\".
|
-- character encoding for HTML data. This function would return \"text/html\".
|
||||||
simpleContentType :: ContentType -> ContentType
|
simpleContentType :: ContentType -> ContentType
|
||||||
simpleContentType = fst . B.breakByte 59 -- 59 == ;
|
simpleContentType = fst . B.break (== _semicolon)
|
||||||
|
|
||||||
-- Give just the media types as a pair.
|
-- Give just the media types as a pair.
|
||||||
-- For example, \"text/html; charset=utf-8\" returns ("text", "html")
|
-- For example, \"text/html; charset=utf-8\" returns ("text", "html")
|
||||||
contentTypeTypes :: ContentType -> (B.ByteString, B.ByteString)
|
contentTypeTypes :: ContentType -> (B.ByteString, B.ByteString)
|
||||||
contentTypeTypes ct = (main, fst $ B.breakByte semicolon (tailEmpty sub))
|
contentTypeTypes ct = (main, fst $ B.break (== _semicolon) (tailEmpty sub))
|
||||||
where
|
where
|
||||||
tailEmpty x = if B.null x then "" else B.tail x
|
tailEmpty x = if B.null x then "" else B.tail x
|
||||||
(main, sub) = B.breakByte slash ct
|
(main, sub) = B.break (== _slash) ct
|
||||||
slash = 47
|
|
||||||
semicolon = 59
|
|
||||||
|
|
||||||
|
|
||||||
instance HasContentType a => HasContentType (DontFullyEvaluate a) where
|
instance HasContentType a => HasContentType (DontFullyEvaluate a) where
|
||||||
getContentType = getContentType . liftM unDontFullyEvaluate
|
getContentType = getContentType . liftM unDontFullyEvaluate
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user