Skip to content

Commit

Permalink
Add base64TextLenient
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimbo4350 committed Jan 4, 2025
1 parent 54bc615 commit e964b9c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Data/RdsData/Decode/Row.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module Data.RdsData.Decode.Row
, bytestring
, lazyBytestring
, base64Text
, base64TextLenient
, lazyBase64Text
, timeOfDay
, day
Expand Down Expand Up @@ -175,6 +176,10 @@ base64Text :: DecodeRow ByteString
base64Text =
column DV.base64Text

base64TextLenient :: DecodeRow ByteString
base64TextLenient =
column DV.base64TextLenient

lazyBase64Text :: DecodeRow LBS.ByteString
lazyBase64Text =
column DV.lazyBase64Text
Expand Down
7 changes: 7 additions & 0 deletions src/Data/RdsData/Decode/Value.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module Data.RdsData.Decode.Value
, lazyText
, lazyBytestring
, base64Text
, base64TextLenient
, lazyBase64Text
, string
, json
Expand Down Expand Up @@ -262,6 +263,12 @@ base64Text = do
Right a -> pure a
Left e -> decodeValueFailed "base64-text" "Text" (Just (T.pack e))

base64TextLenient :: DecodeValue ByteString
base64TextLenient = do
t <- text
let b64 = T.encodeUtf8 t
pure $ B64.decodeLenient b64

lazyBase64Text :: DecodeValue LBS.ByteString
lazyBase64Text = do
t <- lazyText
Expand Down

0 comments on commit e964b9c

Please sign in to comment.