Skip to content

Commit

Permalink
Merge pull request #4529 from unisonweb/runarorama/fixNatToHex
Browse files Browse the repository at this point in the history
Fix bug in `Bytes.fromBase16` when chunks have an odd size
  • Loading branch information
runarorama authored Dec 21, 2023
2 parents 5e98e80 + a14d683 commit 8e12c77
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions lib/unison-util-bytes/src/Unison/Util/Bytes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -370,13 +370,7 @@ arrayToChunk bs = case BA.convert bs :: Block Word8 of
chunkFromArray = arrayToChunk

fromBase16 :: Bytes -> Either Text.Text Bytes
fromBase16 bs = case traverse convert (chunks bs) of
Left e -> Left (Text.pack e)
Right bs -> Right (fromChunks bs)
where
convert b =
BE.convertFromBase BE.Base16 (chunkToArray @BA.Bytes b)
<&> arrayToChunk @BA.Bytes
fromBase16 = fromBase BE.Base16

toBase32, toBase64, toBase64UrlUnpadded :: Bytes -> Bytes
toBase32 = toBase BE.Base32
Expand Down

0 comments on commit 8e12c77

Please sign in to comment.