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"
|
||||
|
||||
const generateStringFromRegex = (pattern) => {
|
||||
const randexp = new RandExp(pattern)
|
||||
return randexp.gen()
|
||||
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 = {
|
||||
|
||||
Reference in New Issue
Block a user