Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash with JSON-LD data #182

Closed
AndrewKvalheim opened this issue Apr 4, 2022 · 8 comments · Fixed by #183
Closed

Crash with JSON-LD data #182

AndrewKvalheim opened this issue Apr 4, 2022 · 8 comments · Fixed by #183

Comments

@AndrewKvalheim
Copy link

htmlnano 2.0.1 crashes when processing JSON-LD data:

$ yarn add htmlnano@2.0.1
$ node --eval "require('htmlnano').process('<script type=application/ld+json>{}</script>')"
…/node_modules/htmlnano/lib/modules/removeComments.js:34
    return contents.filter(content => !isCommentToRemove(content, removeType));
                    ^

TypeError: contents.filter is not a function
    at …/node_modules/htmlnano/lib/modules/removeComments.js:34:21
    at …/node_modules/htmlnano/lib/htmlnano.js:139:28
    at traverse (…/node_modules/posthtml/lib/api.js:105:26)
    at Array.walk (…/node_modules/posthtml/lib/api.js:39:10)
    at …/node_modules/htmlnano/lib/htmlnano.js:122:12
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

I’ve used empty data here for brevity but this also happens with ordinary Schema.org content.

@mischnic
Copy link

mischnic commented Apr 5, 2022

Also appears to happen with SVG: parcel-bundler/parcel#7906

@maltsev
Copy link
Member

maltsev commented Apr 5, 2022

Sorry about the bug!

I deprecated this new version. Please use 2.0.0 for the time being until the bug is fixed.

@SukkaW is it something you can fix?

@SukkaW
Copy link
Contributor

SukkaW commented Apr 5, 2022

Sorry about the bug!

I deprecated this new version. Please use 2.0.0 for the time being until the bug is fixed.

@SukkaW is it something you can fix?

I will work on it ASAP. Don't know why the change passes our unit tests though.

SukkaW added a commit to SukkaW/htmlnano that referenced this issue Apr 6, 2022
SukkaW added a commit to SukkaW/htmlnano that referenced this issue Apr 6, 2022
SukkaW added a commit to SukkaW/htmlnano that referenced this issue Apr 6, 2022
maltsev added a commit that referenced this issue Apr 6, 2022
Fix(#182): correct types and type checks
@maltsev
Copy link
Member

maltsev commented Apr 6, 2022

I released the new version of htmlnano (2.0.2) with the bugfix.

@dannya
Copy link

dannya commented Sep 1, 2022

@maltsev please can you update the GitHub releases too, it still shows 2.0.1 as the latest.

@SukkaW
Copy link
Contributor

SukkaW commented Sep 1, 2022

@dannya 2.0.2 is released on npm and includes the fix.

@dannya
Copy link

dannya commented Sep 1, 2022

@SukkaW sure, so might as well update the GitHub release too!

image

@maltsev
Copy link
Member

maltsev commented Sep 1, 2022

Sorry, forgot about that. I just created the release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants