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 <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
hellopao authored and jasnell committed Dec 23, 2015
1 parent 62d17c1 commit 301e166
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 301e166

Please sign in to comment.