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

Different output at node and at browser #9

Open
istarkov opened this issue Sep 1, 2018 · 3 comments
Open

Different output at node and at browser #9

istarkov opened this issue Sep 1, 2018 · 3 comments

Comments

@istarkov
Copy link

istarkov commented Sep 1, 2018

simple example

const insane = require('insane');
console.log(insane('<a href="&#106;">test</a>'));

Running this under node gives <a href="j">test</a> see https://repl.it/repls/CloseMassiveArchitects
And running this under browser gives <a href="&amp;#106;">test</a> see https://codesandbox.io/s/k3ql74k5y5

This causes an issues with server side rendering.

@istarkov
Copy link
Author

istarkov commented Sep 1, 2018

The issue is that for browser used escape/unescapeHtml from ./she.js but he.decode/encode at node
@bevacqua what the reason to use 2 different method of conversion depending on env?

@istarkov
Copy link
Author

istarkov commented Sep 1, 2018

I just checked and in both cases sanitize-html uses decode/encode so both output of above is <a href="j">test</a>

@istarkov
Copy link
Author

istarkov commented Sep 1, 2018

I think you did that to reduce dependency size at browser level? If yes it's possibly better to use she.js in both environments, otherwise it's hard to use the library with server side rendering libs like React. See #10

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

No branches or pull requests

1 participant