Skip to content

Commit 0a0e85e

Browse files
committed
fix: blank strings are equal
1 parent a772b10 commit 0a0e85e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ export class HtmlDiffer {
5858
* @returns {Boolean}
5959
*/
6060
async isEqual(html1, html2) {
61+
if (html1 === html2) {
62+
return true;
63+
}
64+
6165
const diff = await this.diffHtml(html1, html2);
6266

6367
return (diff.length === 1 && !diff[0].added && !diff[0].removed);

test/differ/isEqual.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,11 @@ describe('\'isEqual\'', function() {
180180

181181
invalidPreset.must.throw(Error);
182182
});
183+
184+
it('blank values are equal', async function() {
185+
const htmlDiffer = new HtmlDiffer();
186+
const isEqual = await htmlDiffer.isEqual('', '');
187+
188+
isEqual.must.be.true();
189+
});
183190
});

0 commit comments

Comments
 (0)