From 22d8b9e9fc57dc9952ed44b3027e2ade7f9746e5 Mon Sep 17 00:00:00 2001 From: Maksym Tsymbarov Date: Tue, 28 Apr 2026 09:05:34 +0200 Subject: [PATCH] Optimized code --- ui-ngx/src/app/core/utils.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ui-ngx/src/app/core/utils.ts b/ui-ngx/src/app/core/utils.ts index 903e3d1e03..6c12e94560 100644 --- a/ui-ngx/src/app/core/utils.ts +++ b/ui-ngx/src/app/core/utils.ts @@ -209,13 +209,19 @@ export function objToBase64(obj: any): string { })); } +const textDecoderUtf8 = new TextDecoder('utf-8', { fatal: true }); +const textDecoderLatin1 = new TextDecoder('iso-8859-1'); + export function base64toString(b64Encoded: string): string { const binary = atob(b64Encoded); - const bytes = Uint8Array.from(binary, c => c.charCodeAt(0)); + const bytes = new Uint8Array(binary.length); + for (let i = 0; i < binary.length; i++) { + bytes[i] = binary.charCodeAt(i); + } try { - return new TextDecoder('utf-8', { fatal: true }).decode(bytes); + return textDecoderUtf8.decode(bytes); } catch { - return new TextDecoder('iso-8859-1').decode(bytes); + return textDecoderLatin1.decode(bytes); } }