fix(fn): RandExp error should not cause UI to completely fail (#7940)
* regexp syntax varies across languages
This commit is contained in:
@@ -6,8 +6,13 @@ import { objectify, isFunc, normalizeArray, deeplyStripKey } from "core/utils"
|
|||||||
import memoizeN from "../../../helpers/memoizeN"
|
import memoizeN from "../../../helpers/memoizeN"
|
||||||
|
|
||||||
const generateStringFromRegex = (pattern) => {
|
const generateStringFromRegex = (pattern) => {
|
||||||
|
try {
|
||||||
const randexp = new RandExp(pattern)
|
const randexp = new RandExp(pattern)
|
||||||
return randexp.gen()
|
return randexp.gen()
|
||||||
|
} catch (e) {
|
||||||
|
// Invalid regex should not cause a crash (regex syntax varies across languages)
|
||||||
|
return "string"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const primitives = {
|
const primitives = {
|
||||||
|
|||||||
Reference in New Issue
Block a user