added check for no matches (#1673)
This commit is contained in:
parent
419d279db7
commit
5e17450e2f
|
|
@ -54,11 +54,14 @@ const ACTION_ANONYMOUS_FUNC_REGEX = /\(\) => (({[\s\S]*?})|([\s\S]*?)(\([\s\S]*?
|
||||||
const IS_URL_OR_MODAL = /^'.*'$/;
|
const IS_URL_OR_MODAL = /^'.*'$/;
|
||||||
const modalSetter = (changeValue: any, currentValue: string) => {
|
const modalSetter = (changeValue: any, currentValue: string) => {
|
||||||
const matches = [...currentValue.matchAll(ACTION_TRIGGER_REGEX)];
|
const matches = [...currentValue.matchAll(ACTION_TRIGGER_REGEX)];
|
||||||
const args = matches[0][2].split(",");
|
let args: string[] = [];
|
||||||
if (isDynamicValue(changeValue)) {
|
if (matches.length) {
|
||||||
args[0] = `${changeValue.substring(2, changeValue.length - 2)}`;
|
args = matches[0][2].split(",");
|
||||||
} else {
|
if (isDynamicValue(changeValue)) {
|
||||||
args[0] = `'${changeValue}'`;
|
args[0] = `${changeValue.substring(2, changeValue.length - 2)}`;
|
||||||
|
} else {
|
||||||
|
args[0] = `'${changeValue}'`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return currentValue.replace(
|
return currentValue.replace(
|
||||||
ACTION_TRIGGER_REGEX,
|
ACTION_TRIGGER_REGEX,
|
||||||
|
|
@ -130,9 +133,12 @@ const textSetter = (
|
||||||
argNum: number,
|
argNum: number,
|
||||||
): string => {
|
): string => {
|
||||||
const matches = [...currentValue.matchAll(ACTION_TRIGGER_REGEX)];
|
const matches = [...currentValue.matchAll(ACTION_TRIGGER_REGEX)];
|
||||||
const args = argsStringToArray(matches[0][2]);
|
let args: string[] = [];
|
||||||
const jsVal = stringToJS(changeValue);
|
if (matches.length) {
|
||||||
args[argNum] = jsVal;
|
args = argsStringToArray(matches[0][2]);
|
||||||
|
const jsVal = stringToJS(changeValue);
|
||||||
|
args[argNum] = jsVal;
|
||||||
|
}
|
||||||
const result = currentValue.replace(
|
const result = currentValue.replace(
|
||||||
ACTION_TRIGGER_REGEX,
|
ACTION_TRIGGER_REGEX,
|
||||||
`{{$1(${args.join(",")})}}`,
|
`{{$1(${args.join(",")})}}`,
|
||||||
|
|
@ -157,8 +163,11 @@ const enumTypeSetter = (
|
||||||
argNum: number,
|
argNum: number,
|
||||||
): string => {
|
): string => {
|
||||||
const matches = [...currentValue.matchAll(ACTION_TRIGGER_REGEX)];
|
const matches = [...currentValue.matchAll(ACTION_TRIGGER_REGEX)];
|
||||||
const args = argsStringToArray(matches[0][2]);
|
let args: string[] = [];
|
||||||
args[argNum] = changeValue as string;
|
if (matches.length) {
|
||||||
|
args = argsStringToArray(matches[0][2]);
|
||||||
|
args[argNum] = changeValue as string;
|
||||||
|
}
|
||||||
const result = currentValue.replace(
|
const result = currentValue.replace(
|
||||||
ACTION_TRIGGER_REGEX,
|
ACTION_TRIGGER_REGEX,
|
||||||
`{{$1(${args.join(",")})}}`,
|
`{{$1(${args.join(",")})}}`,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user