From: Mihai Bazon Date: Sun, 26 Jan 2014 08:05:55 +0000 (+0200) Subject: Move unescaping regexps under a codegen option (`unescape_regexps`) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=ceb200fe81b42e0abd2242018530d6d952eb058d;p=UglifyJS.git Move unescaping regexps under a codegen option (`unescape_regexps`) --- diff --git a/lib/output.js b/lib/output.js index c2f49e9e..55039030 100644 --- a/lib/output.js +++ b/lib/output.js @@ -46,22 +46,23 @@ function OutputStream(options) { options = defaults(options, { - indent_start : 0, - indent_level : 4, - quote_keys : false, - space_colon : true, - ascii_only : false, - inline_script : false, - width : 80, - max_line_len : 32000, - beautify : false, - source_map : null, - bracketize : false, - semicolons : true, - comments : false, - preserve_line : false, - screw_ie8 : false, - preamble : null, + indent_start : 0, + indent_level : 4, + quote_keys : false, + space_colon : true, + ascii_only : false, + unescape_regexps : false, + inline_script : false, + width : 80, + max_line_len : 32000, + beautify : false, + source_map : null, + bracketize : false, + semicolons : true, + comments : false, + preserve_line : false, + screw_ie8 : false, + preamble : null, }, true); var indentation = 0; @@ -1150,7 +1151,7 @@ function OutputStream(options) { var str = self.getValue().toString(); if (output.option("ascii_only")) { str = output.to_ascii(str); - } else { + } else if (output.option("unescape_regexps")) { str = str.split("\\\\").map(function(str){ return str.replace(/\\u[0-9a-fA-F]{4}|\\x[0-9a-fA-F]{2}/g, function(s){ var code = parseInt(s.substr(2), 16);