diff options
-rw-r--r-- | HTTP.hs | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -93,8 +93,8 @@ instance ToHttpApiData ProofOfWork where <> ":" <> b64 b instance FromHttpApiData ProofOfWork where parseUrlPiece t = do - let (salt, rest) = T.break (/= ':') t - let (hmac, rest') = T.break (/= ':') rest + let (salt, rest) = T.break (== ':') t + let (hmac, rest') = T.break (== ':') (T.drop 1 rest) b <- unb64 (T.drop 1 rest') return $ ProofOfWork b $ RequestID { randomSalt = RandomSalt salt @@ -105,6 +105,7 @@ b64 :: B.ByteString -> Text b64 v = T.decodeUtf8 $ Raaz.toByteString (Raaz.encode v :: Raaz.Base64) unb64 :: Monad m => Text -> m B.ByteString -unb64 t = maybe (fail "bad base64 data") (return . Raaz.decodeFormat) f - where - f = Raaz.fromByteString (T.encodeUtf8 t) :: Maybe Raaz.Base64 +unb64 t = maybe + (fail "bad base64 data") + (return . Raaz.decodeFormat) + (Raaz.fromByteString (T.encodeUtf8 t) :: Maybe Raaz.Base64) |