mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-02-09 08:38:53 +01:00
Escape commas in comma-separated random and pick
This commit is contained in:
parent
65cf9c8f4d
commit
d8949fddc7
@ -197,7 +197,8 @@ function randomReplace(input, emptyListPlaceholder = '') {
|
||||
// Split on either double colons or comma. If comma is the separator, we are also trimming all items.
|
||||
const list = listString.includes('::')
|
||||
? listString.split('::')
|
||||
: listString.split(',').map(item => item.trim());
|
||||
// Replaced escaped commas with a placeholder to avoid splitting on them
|
||||
: listString.replace(/\\,/g, '##<23>COMMA<4D>##').split(',').map(item => item.trim().replace(/##<23>COMMA<4D>##/g, ','));
|
||||
|
||||
if (list.length === 0) {
|
||||
return emptyListPlaceholder;
|
||||
@ -221,7 +222,8 @@ function pickReplace(input, rawContent, emptyListPlaceholder = '') {
|
||||
// Split on either double colons or comma. If comma is the separator, we are also trimming all items.
|
||||
const list = listString.includes('::')
|
||||
? listString.split('::')
|
||||
: listString.split(',').map(item => item.trim());
|
||||
// Replaced escaped commas with a placeholder to avoid splitting on them
|
||||
: listString.replace(/\\,/g, '##<23>COMMA<4D>##').split(',').map(item => item.trim().replace(/##<23>COMMA<4D>##/g, ','));
|
||||
|
||||
if (list.length === 0) {
|
||||
return emptyListPlaceholder;
|
||||
|
Loading…
x
Reference in New Issue
Block a user