Skip to content

Commit

Permalink
util: use regexp instead of str.replace().join()
Browse files Browse the repository at this point in the history
PR-URL: #3689
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
hellopao authored and jasnell committed Nov 6, 2015
1 parent d26927c commit 02a44e0
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 02a44e0

Please sign in to comment.