API reference › @evolu/common › Type › Base64Url
const Base64Url: brand(
"Base64Url",
String,
(value: string): Result<string, Base64UrlError> => {
// Round-trip validation ensures consistency across different base64url
// implementations (Node.js Buffer, native browser API, manual fallback).
// Only strings that decode and encode identically are accepted.
let roundTrip;
try {
roundTrip = uint8ArrayToBase64Url(
base64UrlToUint8Array(value as Base64Url),
);
} catch {
//
}
return roundTrip === value
? ok(value)
: err<Base64UrlError>({ type: "Base64Url", value });
},
);
Defined in: packages/common/src/Type.ts:1569
Base64Url without padding.
Encode with uint8ArrayToBase64Url, decode with base64UrlToUint8Array.