Package: effect
Module: Encoding
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?"
}
Signature
declare const decodeBase64UrlString: (str: string) => Result.Result<string, EncodingError>
Since v2.0.0