diff --git a/__tests__/__snapshots__/index.js.snap b/__tests__/__snapshots__/index.js.snap index 413a0c2..f5fde62 100644 --- a/__tests__/__snapshots__/index.js.snap +++ b/__tests__/__snapshots__/index.js.snap @@ -1,7 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`should beautify HTML 1`] = ` -
- `; exports[`should only act on HTML strings 1`] = `"Some text without any tags."`; diff --git a/index.js b/index.js index 83945ce..a0cf8c5 100644 --- a/index.js +++ b/index.js @@ -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(); }, };