We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 52c355c commit 30854acCopy full SHA for 30854ac
1 file changed
src/lib/util.js
@@ -88,8 +88,8 @@ function highlight(text, line, count) {
88
89
function outdent(str, prefix='', width=80) {
90
str = str.replace(/(^\n+|\n+$)/g, '').replace(/\t/, ' ');
91
- let indents = str.match(/^[ -]+/gm);
92
- let minLength = indents.reduce( (indent, value) => Math.min(indent, value.length), indents[0].length);
+ let indents = str.match(/^[ -]+/gm) || [];
+ let minLength = indents.reduce( (indent, value) => Math.min(indent, value.length), indents[0] ? indents[0].length : 0);
93
str = str.replace(/^[ -]+/gm, str => prefix+str.substring(minLength));
94
str = str.replace(/^.*$/gm, str => str.substring(0, width));
95
return str;
0 commit comments