img allowedTags throwing an error in Nuxt.js
See original GitHub issueTo Reproduce
Not too sure how to reproduce, Using this in a Nuxt.js application, with the issue occurring during SSR on the latest version of sanitize-html.
Following the docs, I added { allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img']) }
to allow img tags, this worked fine in version 2.1.0.
Updating to 2.4.0, nuxt starts throwing a very non-descript error “TypeError: isPlainObject is not a function”, with no other stack traces.
Assuming this is some typescript querk, I changed the configuration to: { allowedTags: [...sanitizeHtml.defaults.allowedTags, 'img'] }
and it now works like before. 🤷♂️
Expected behavior
The sanitizeHtml.defaults.allowedTags.concat
method described in the readme to work, without throwing errors.
Describe the bug
Looks like allowedTags
isn’t a “plain” array, so it’s causing issues when passed as an option.
Details
Version of Node.js: Observed on both 12.16.1 and 14.16.1
Server Operating System: Observed on Linux and MacOS X
Additional context: Nuxt version 2.14.6
Maybe the fix is just to update the readme to not use concat?
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
@boutell you’re exactly right. Both version 5.0.0 and version 3.x of is-plain-object are installed, and my webpack config (which is nontrivial for some other complicated reasons) is evidently messing up the module resolution. This is definitely not at all something that is wrong with sanitize-html, and I was wrong.
@dosstx I don’t think there’s any reason why you couldn’t.