reduce false positives from object literals (#2935)
authorAlex Lam S.L <alexlamsl@gmail.com>
Sun, 18 Feb 2018 22:21:07 +0000 (06:21 +0800)
committerGitHub <noreply@github.com>
Sun, 18 Feb 2018 22:21:07 +0000 (06:21 +0800)
test/sandbox.js

index d823866..b534613 100644 (file)
@@ -42,7 +42,7 @@ var FUNC_TOSTRING = [
     "        }",
     "        var body = toString.call(this);",
     '        body = body.slice(body.indexOf("{") + 1, -1);',
-    '        if (/^(?:\\s|\\{|\\}|;|[0-9\\.]+|"[^"]*"|\\w+:|var [^=;]+|\\/\\/.*|\\/\\*[\\s\\S]*\\*\\/)*(?:$|return(?:;|\\n))/.test(body)) {',
+    '        if (/^(?:[\\s{}();,]|[0-9\\.]+|"[^"]*"|\\w+:|var [^=;]+|\\/\\/.*|\\/\\*[\\s\\S]*\\*\\/)*(?:$|return(?:$|;|\\n))/.test(body)) {',
     '            body = "";',
     "        } else {",
     '            body = n + "' + function() {