fix corner case in templates (#4607)

fixes #4606
This commit is contained in:
Alex Lam S.L
2021-02-01 18:29:43 +00:00
committed by GitHub
parent b27b6807cb
commit 7110c6923b
2 changed files with 18 additions and 1 deletions

View File

@@ -9956,7 +9956,9 @@ merge(Compressor.prototype, {
var node = exprs[i];
var ev = node.evaluate(compressor);
if (ev === node) continue;
ev = "" + ev;
ev = ("" + ev).replace(/\r|\\|`/g, function(s) {
return "\\" + (s == "\r" ? "r" : s);
});
if (ev.length > node.print_to_string().length + 3) continue;
exprs.splice(i, 1);
strs.splice(i, 2, strs[i] + ev + strs[i + 1]);