Skip to content

Commit

Permalink
feat: trim diffed HTML output (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
scotthovestadt authored and rayrutjes committed Apr 23, 2019
1 parent 631bfd3 commit aa47789
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 0 additions & 2 deletions __tests__/__snapshots__/index.js.snap
@@ -1,7 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`should beautify HTML 1`] = `
<div id="header">
<a id="logo"
href="/"
Expand Down Expand Up @@ -209,7 +208,6 @@ exports[`should beautify HTML 1`] = `
</li>
</ul>
</div>
`;
exports[`should only act on HTML strings 1`] = `"Some text without any tags."`;
Expand Down
9 changes: 7 additions & 2 deletions index.js
Expand Up @@ -2,9 +2,14 @@ var toDiffableHtml = require('diffable-html');

module.exports = {
test(object) {
return typeof object === 'string' && object.trim()[0] === '<';
if (typeof object !== 'string') {
return false;
}

const trimmed = object.trim();
return trimmed.length > 2 && trimmed[0] === '<' && trimmed[trimmed.length - 1] === '>';
},
print(val) {
return toDiffableHtml(val);
return toDiffableHtml(val).trim();
},
};

0 comments on commit aa47789

Please sign in to comment.