fix(utils): node v8 not support dotAll in regex (#5608)

This commit is contained in:
Xin Du (Clark) 2019-04-26 20:16:16 +01:00 committed by pooya parsa
parent b7284e1b4a
commit a21555c8cd
1 changed files with 3 additions and 3 deletions

View File

@ -14,11 +14,11 @@ export function normalizeFunctions(obj) {
}
if (typeof obj[key] === 'function') {
const asString = obj[key].toString()
const match = asString.match(/^([^{(]+)=>\s*(.*)/s)
const match = asString.match(/^([^{(]+)=>\s*([\0-\uFFFF]*)/)
if (match) {
const fullFunctionBody = match[2].match(/^{?(\s*return\s+)?(.*?)}?$/s)
const fullFunctionBody = match[2].match(/^{?(\s*return\s+)?([\0-\uFFFF]*?)}?$/)
let functionBody = fullFunctionBody[2].trim()
if (fullFunctionBody[1] || !match[2].trim().match(/^\s*{/s)) {
if (fullFunctionBody[1] || !match[2].trim().match(/^\s*{/)) {
functionBody = `return ${functionBody}`
}
// eslint-disable-next-line no-new-func