2
0

🚑 Allow for regex without slashes for retro compat

This commit is contained in:
Baptiste Arnaud
2024-04-02 11:13:55 +02:00
parent a0ba8c5c2a
commit 2663ca2e18
3 changed files with 7 additions and 4 deletions

View File

@ -176,9 +176,10 @@ const parseDateOrNumber = (value: string): number => {
}
const preprocessRegex = (regex: string) => {
const match = regex.match(/^\/([^\/]+)\/([gimuy]*)$/)
const regexWithFlags = regex.match(/\/(.+)\/([gimuy]*)$/)
if (!match) return null
if (regexWithFlags)
return { pattern: regexWithFlags[1], flags: regexWithFlags[2] }
return { pattern: match[1], flags: match[2] }
return { pattern: regex }
}