Skip to content

Commit

Permalink
[PROD-40813] Allow safeHtml to support no-html rule (#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
klesgidis authored Apr 29, 2024
1 parent e0e8664 commit 7812530
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/initializers/joi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ const Joi: JoiWithExtensions = _Joi.extend(
args: [
{
name: 'allowedTags',
assert: value => Array.isArray(value) && value.length > 0,
message: 'must be a non empty array'
}
],
Expand All @@ -275,7 +274,6 @@ const Joi: JoiWithExtensions = _Joi.extend(
args: [
{
name: 'allowedAttributes',
assert: value => typeof value === 'object' && Object.keys(value).length > 0,
message: 'must be a non empty object'
}
],
Expand Down
4 changes: 4 additions & 0 deletions test/initializers/joi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ describe('joi extensions', function () {
.should
.equal('<a href="http://google.com" class="aclass"></a>foo');
});
it('no html at all', function () {
Joi.safeHtml().allowedAttributes({}).allowedTags([])
.validate('<p>banana</p>').value.should.equal('banana');
});
});

describe('objectid', function () {
Expand Down

0 comments on commit 7812530

Please sign in to comment.