api-builder: trim blank lines from the end of a text block too

This commit is contained in:
Peter Bacon Darwin 2015-11-10 11:20:13 +00:00
parent 096e5f081b
commit 93c187de2a
2 changed files with 6 additions and 3 deletions

View File

@ -6,6 +6,9 @@ module.exports = function() {
while(lines.length && (lines[0].trim() === '')) {
lines.shift();
}
while(lines.length && (lines[lines.length-1].trim() === '')) {
lines.pop();
}
return lines.join('\n');
}
};

View File

@ -11,8 +11,8 @@ describe('trimBlankLines filter', function() {
expect(filter.name).toEqual('trimBlankLines');
});
it('should remove all empty lines from the start of the string', function() {
it('should remove empty lines from the start and end of the string', function() {
expect(filter.process('\n \n\nsome text\n \nmore text\n \n'))
.toEqual('some text\n\nmore text\n\n');
.toEqual('some text\n \nmore text');
});
});