From 422b9e1b631790f0cdd471b5217f46fae9bbb75f Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Tue, 2 Apr 2024 18:34:29 +0300 Subject: [PATCH] Fix sequences to stop strings if missing values --- public/scripts/instruct-mode.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/public/scripts/instruct-mode.js b/public/scripts/instruct-mode.js index 033794009..d90ffb9bc 100644 --- a/public/scripts/instruct-mode.js +++ b/public/scripts/instruct-mode.js @@ -243,12 +243,12 @@ export function getInstructStoppingSequences() { const result = []; if (power_user.instruct.enabled) { - const stop_sequence = power_user.instruct.stop_sequence; - const input_sequence = power_user.instruct.input_sequence.replace(/{{name}}/gi, name1); - const output_sequence = power_user.instruct.output_sequence.replace(/{{name}}/gi, name2); - const first_output_sequence = power_user.instruct.first_output_sequence.replace(/{{name}}/gi, name2); - const last_output_sequence = power_user.instruct.last_output_sequence.replace(/{{name}}/gi, name2); - const system_sequence = power_user.instruct.system_sequence.replace(/{{name}}/gi, 'System'); + const stop_sequence = power_user.instruct.stop_sequence || ''; + const input_sequence = power_user.instruct.input_sequence?.replace(/{{name}}/gi, name1) || ''; + const output_sequence = power_user.instruct.output_sequence?.replace(/{{name}}/gi, name2) || ''; + const first_output_sequence = power_user.instruct.first_output_sequence?.replace(/{{name}}/gi, name2) || ''; + const last_output_sequence = power_user.instruct.last_output_sequence?.replace(/{{name}}/gi, name2) || ''; + const system_sequence = power_user.instruct.system_sequence?.replace(/{{name}}/gi, 'System') || ''; const combined_sequence = `${stop_sequence}\n${input_sequence}\n${output_sequence}\n${first_output_sequence}\n${last_output_sequence}\n${system_sequence}`;