diff --git a/public/script.js b/public/script.js index 8808320c8..eed5022e5 100644 --- a/public/script.js +++ b/public/script.js @@ -5426,9 +5426,11 @@ export function cleanUpMessage(getMessage, isImpersonate, isContinue, displayInc getMessage = fixMarkdown(getMessage, false); } - const nameToTrim2 = isImpersonate ? name1 : name2; + const nameToTrim2 = isImpersonate + ? (!power_user.allow_name1_display ? name1 : '') + : (!power_user.allow_name2_display ? name2 : ''); - if (getMessage.startsWith(nameToTrim2 + ':')) { + if (nameToTrim2 && getMessage.startsWith(nameToTrim2 + ':')) { getMessage = getMessage.replace(nameToTrim2 + ':', ''); getMessage = getMessage.trimStart(); }