question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

img allowedTags throwing an error in Nuxt.js

See original GitHub issue

To 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:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
williamsteincommented, Aug 16, 2021

@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.

0reactions
abeacommented, Oct 18, 2021

@dosstx I don’t think there’s any reason why you couldn’t.

Read more comments on GitHub >

github_iconTop Results From Across the Web

nuxtjs vuejs @error is not firing in a component when trying to ...
When an image throws a 404 I want to load a fallback image. So far so good. However the @error function never fires...
Read more >
Not firing @error event on img element #5493 - nuxt/nuxt.js
First i comment out the code and start my local nuxt.js cli , the error event will be fire . And then i...
Read more >
Consolidating Error Handling in Nuxt Apps - Zaengle Corp
In this post, we'll discuss how we previously handled Axios errors in our Nuxt apps, why this approach was problematic, and how we...
Read more >
Options - Froala
Plugin: code_beautifier.min.js ... The list of allowed tags. ... Keeps the editor visible next to the cursor even when there is no selection....
Read more >
nuxt-img
Uses built-in provider to optimize local and remote images · Converts src to provider optimized URLs · Automatically resizes images based on width...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found