mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Fix pattern checking on /replace
This commit is contained in:
@ -2079,8 +2079,9 @@ export function initDefaultSlashCommands() {
|
|||||||
name: 'replace',
|
name: 'replace',
|
||||||
aliases: ['re'],
|
aliases: ['re'],
|
||||||
callback: (async ({ mode = 'literal', pattern, replacer = '' }, text) => {
|
callback: (async ({ mode = 'literal', pattern, replacer = '' }, text) => {
|
||||||
if (pattern === '')
|
if (!pattern) {
|
||||||
throw new Error('Argument of \'pattern=\' cannot be empty');
|
throw new Error('Argument of \'pattern=\' cannot be empty');
|
||||||
|
}
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case 'literal':
|
case 'literal':
|
||||||
return text.replaceAll(pattern, replacer);
|
return text.replaceAll(pattern, replacer);
|
||||||
|
Reference in New Issue
Block a user