mirror of
https://github.com/hexastack/hexabot
synced 2024-11-23 01:55:15 +00:00
fix(frontend): visual editor pattern UI representation
This commit is contained in:
parent
6b387b826b
commit
203747a2a4
@ -268,19 +268,14 @@ const PatternInput: FC<PatternInputProps> = ({
|
||||
{...registerInput(t("message.regex_is_invalid"), idx, {
|
||||
validate: (pattern) => {
|
||||
try {
|
||||
if (
|
||||
pattern.at(0) === "/" &&
|
||||
pattern.at(-1) === "/" &&
|
||||
typeof pattern === "string"
|
||||
)
|
||||
new RegExp(pattern.slice(1, -1));
|
||||
if (isRegex(pattern)) new RegExp(pattern.slice(1, -1));
|
||||
|
||||
return true;
|
||||
} catch (_e) {
|
||||
return t("message.regex_is_invalid");
|
||||
}
|
||||
},
|
||||
setValueAs: (v) => `/${v}/`,
|
||||
setValueAs: (v) => (isRegex(v) ? v : `/${v}/`),
|
||||
})}
|
||||
label={t("label.regex")}
|
||||
value={value.slice(1, -1)}
|
||||
|
Loading…
Reference in New Issue
Block a user