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 rvagg committed Nov 7, 2015
1 parent b14d9c5 commit 9a45c21
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 9a45c21

Please sign in to comment.