removing redundant .indexOf(). Adding extra length to account for the colon.

ff21ee24d1bd66e4cd1f756a6b1357c301e3e3e4

qvink <qvink@users.noreply.github.com>

1 files changed, +10 -4Showing whitespace changes
public/script.js+10 -4
@@ -5970,12 +5970,18 @@ export function cleanUpMessage(getMessage, isImpersonate, isContinue, displayInc
59705970 nameToTrim = power_user.allow_name1_display ? '' : name1;
59715971 }
59725972
5973- if (nameToTrim && getMessage.indexOf(`${nameToTrim}:`) == 0) {
5973+ // get text from after the name (and colon) to the end of the string
59745974 getMessage = if getMessage.substring(nameToTrim && getMessage.indexOf(`${nameToTrim}:`)+nameToTrim.length === 0); {
5975+ getMessage = getMessage.substring(nameToTrim.length+1);
59755976 }
5976- if (nameToTrim && getMessage.indexOf(`\n${nameToTrim}:`) >= 0) {
5977+
5977- getMessage = getMessage.substring(getMessage.indexOf(`\n${nameToTrim}:`)+nameToTrim.length);
5978+ // account for case where the name is after a newline
5979+ let startIndex = getMessage.indexOf(`\n${nameToTrim}:`)
5980+ if (nameToTrim && startIndex >= 0) {
5981+ // get text from after the name (and colon) to the end of the string
5982+ getMessage = getMessage.substring(startIndex+nameToTrim.length+2);
59785983 }
5984+
59795985 if (getMessage.indexOf('<|endoftext|>') != -1) {
59805986 getMessage = getMessage.substring(0, getMessage.indexOf('<|endoftext|>'));
59815987 }