mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 08:29:55 +00:00
improvements: address requested changes
This commit is contained in:
@@ -24,17 +24,5 @@ export const isBase64 = (
|
||||
};
|
||||
|
||||
export const getBase64SizeInBytes = (base64String: string) => {
|
||||
// Remove data URI scheme if present
|
||||
const base64 = base64String.replace(/^data:.*?;base64,/, "");
|
||||
|
||||
// Remove padding characters
|
||||
const withoutPadding = base64.replace(/=+$/, "");
|
||||
|
||||
// Calculate bits: each base64 character represents 6 bits
|
||||
const totalBits = withoutPadding.length * 6;
|
||||
|
||||
// Convert bits to bytes (8 bits = 1 byte)
|
||||
const bytes = totalBits / 8;
|
||||
|
||||
return bytes;
|
||||
return Buffer.from(base64String, "base64").length;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user