fix(fn): RandExp error should not cause UI to completely fail (#7940)

* regexp syntax varies across languages
This commit is contained in:
Steven James
2022-03-28 19:29:01 -04:00
committed by GitHub
parent ed344ff836
commit b825e44077

View File

@@ -6,8 +6,13 @@ import { objectify, isFunc, normalizeArray, deeplyStripKey } from "core/utils"
import memoizeN from "../../../helpers/memoizeN"
const generateStringFromRegex = (pattern) => {
try {
const randexp = new RandExp(pattern)
return randexp.gen()
} catch (e) {
// Invalid regex should not cause a crash (regex syntax varies across languages)
return "string"
}
}
const primitives = {