From 240e139a9d837f82ab07dd186459dfdb4070c46a Mon Sep 17 00:00:00 2001 From: qinjia Date: Fri, 6 Nov 2015 17:32:33 +0800 Subject: [PATCH] util: use regexp instead of str.replace().join() --- lib/util.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/util.js b/lib/util.js index 3335faf3d8c51e..090cfd1a39f049 100644 --- a/lib/util.js +++ b/lib/util.js @@ -575,13 +575,9 @@ function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { } if (str.indexOf('\n') > -1) { if (array) { - str = str.split('\n').map(function(line) { - return ' ' + line; - }).join('\n').substr(2); + str = str.replace(/\n/g,'\n '); } else { - str = '\n' + str.split('\n').map(function(line) { - return ' ' + line; - }).join('\n'); + str = str.replace(/(^|\n)/g,'\n '); } } } else {