From 1bc9ddea7edc89877d533ef71a209199852e6c1e Mon Sep 17 00:00:00 2001 From: Xiaoyi Shi Date: Thu, 6 Jun 2013 22:57:34 +0800 Subject: [PATCH] Fixing exception when evaluate regualr exceptions. --- lib/compress.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/compress.js b/lib/compress.js index c812de1e..366a2616 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -168,7 +168,9 @@ merge(Compressor.prototype, { return make_node(AST_Null, orig).optimize(compressor); } if (val instanceof RegExp) { - return make_node(AST_RegExp, orig).optimize(compressor); + return make_node(AST_RegExp, orig, { + value: val + }).optimize(compressor); } throw new Error(string_template("Can't handle constant of type: {type}", { type: typeof val @@ -909,7 +911,11 @@ merge(Compressor.prototype, { var value = def.value.evaluate(compressor, true); def.value = value[0]; if (value.length > 1) { - if (!(typeof value[1] === 'string' && value[1].length >= inlineStringThreshold)) + if (typeof value[1] === 'string' && value[1].length < inlineStringThreshold + || typeof value[1] === 'number' + || typeof value[1] === 'boolean' + || value[1] === null + ) definitions[def.name.name] = value[1]; } }