Skip to content

Commit

Permalink
add testcase for transforming text inside empty tags
Browse files Browse the repository at this point in the history
  • Loading branch information
f0x52 committed Dec 9, 2024
1 parent 98b4900 commit de2aefb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,18 @@ describe('sanitizeHtml', function() {
disallowedTagsMode: 'completelyDiscard'
});

assert.equal(sanitizedHtml, expectedOutput);
});
it('should transform text content of tags even if they originally had none', () => {
const inputHtml = '<div></div>';
const expectedOutput = 'new content';
const sanitizedHtml = sanitizeHtml(inputHtml, {
allowedTags: [],
transformTags: {
"div": () => ({text: "new content"})
}
});

assert.equal(sanitizedHtml, expectedOutput);
});
});

0 comments on commit de2aefb

Please sign in to comment.