Hyperlinkv0.8.0-beta.28

Encoding

Encoding.decodeBase64UrlStringconsteffect/Encoding.ts:388
(str: string): Result.Result<string, EncodingError>

Decodes a URL-safe base64 string into a UTF-8 string safely.

When to use

Use to decode padded or unpadded Base64Url text into UTF-8 text without throwing on invalid input.

Details

Returns Result.succeed with the decoded text when decoding succeeds, or Result.fail with an EncodingError when the input is not valid URL-safe base64.

Example (Decoding URL-safe Base64 strings)

import { Encoding, Result } from "effect"

const result = Encoding.decodeBase64UrlString("aGVsbG8_")
if (Result.isSuccess(result)) {
  console.log(result.success) // "hello?"
}
decoding
export const decodeBase64UrlString = (str: string) => Result.map(decodeBase64Url(str), (_) => decoder.decode(_))
Referenced by 1 symbols