From dcf544306d7a6a2fcab98e00d9129dcd9c2ffd80 Mon Sep 17 00:00:00 2001 From: Lluis Date: Fri, 10 May 2024 11:42:05 +0200 Subject: [PATCH] unmask last character --- handlers/stream.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/handlers/stream.js b/handlers/stream.js index e543502..cd0fad4 100644 --- a/handlers/stream.js +++ b/handlers/stream.js @@ -33,14 +33,22 @@ class Stream { } _maskUserName (userName) { - const unmaskedLength = 3 - let maskedUserName = userName.substring(0,unmaskedLength) + const unmaskedStartLength = 3 + const unmaskedEndLength = 1 + let unmaskedStart = userName.substring(0, unmaskedStartLength) + let masked = '' + let unmaskedEnd = '' + + const unmaskedLength = unmaskedStartLength + unmaskedEndLength if (userName.length > unmaskedLength) { - maskedUserName = maskedUserName + '*'.repeat(userName.length - unmaskedLength) + masked = '*'.repeat(userName.length - unmaskedLength) + unmaskedEnd = userName.substring(userName.length - unmaskedEndLength) + } else if (userName.length > unmaskedStartLength) { + masked = '*'.repeat(userName.length - unmaskedStartLength) } - return maskedUserName + return unmaskedStart + masked + unmaskedEnd } async captureScreenshot(target, bot, notifierBot, displayName, roomId) {