Skip to content

Commit

Permalink
Use official decodeUtf8Lenient from text >= 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fumieval committed Oct 15, 2023
1 parent 07b0035 commit 44ae3d8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Web/Scotty/Util.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE LambdaCase #-}
module Web.Scotty.Util
( lazyTextToStrictByteString
Expand All @@ -23,7 +24,7 @@ import Network.HTTP.Types
import qualified Data.ByteString as B
import qualified Data.Text as TP (Text, pack)

Check warning on line 25 in Web/Scotty/Util.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.4.6

The qualified import of ‘Text’ from module ‘Data.Text’ is redundant

Check warning on line 25 in Web/Scotty/Util.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.6.2

The qualified import of ‘Text’ from module ‘Data.Text’ is redundant
import qualified Data.Text.Lazy as TL
import qualified Data.Text.Encoding as ES
import Data.Text.Encoding as ES
import qualified Data.Text.Encoding.Error as ES

import Web.Scotty.Internal.Types
Expand All @@ -34,8 +35,10 @@ lazyTextToStrictByteString = ES.encodeUtf8 . TL.toStrict
strictByteStringToLazyText :: B.ByteString -> TL.Text
strictByteStringToLazyText = TL.fromStrict . ES.decodeUtf8With ES.lenientDecode

#if !MIN_VERSION_text(2,0,0)
decodeUtf8Lenient :: B.ByteString -> TP.Text
decodeUtf8Lenient = ES.decodeUtf8With ES.lenientDecode
#endif

-- Note: we currently don't support responseRaw, which may be useful
-- for websockets. However, we always read the request body, which
Expand Down

0 comments on commit 44ae3d8

Please sign in to comment.