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

doesn't decode any HTML entities at all #9

Closed
ghost opened this issue Nov 19, 2014 · 2 comments
Closed

doesn't decode any HTML entities at all #9

ghost opened this issue Nov 19, 2014 · 2 comments

Comments

@ghost
Copy link

ghost commented Nov 19, 2014

Hi, thanks for sharing this, but I couldn't get it to decode anything at all.

var Entities = require('html-entities').AllHtmlEntities, entities = new Entities(); console.log(entities.decode('Hello+%22I+think%22+%27therefore+I+am%27+%26+this+is+%7C+fun'));

Shows this in the console:
Hello+%22I+think%22+%27therefore+I+am%27+%26+this+is+%7C+fun

Running version: html-entities@1.1.1 node_modules/html-entities

@mdevils
Copy link
Owner

mdevils commented Nov 19, 2014

Hello, lope.

Thank you for your feedback.

The function you are requesting is url encoding/decoding, not html entities encoding/decoding.

You do not need any library to solve your problem, use the built-in function: decodeURIComponent.

Example:

console.log(decodeURIComponent('Hello+%22I+think%22+%27therefore+I+am%27+%26+this+is+%7C+fun'));

@mdevils mdevils closed this as completed Nov 19, 2014
@ghost
Copy link
Author

ghost commented Nov 19, 2014

Thanks for the quick reply mdevils.

Yeah after trying 3 different npm html-entities decoders and none of them worked I started to wonder "maybe it's not you, it's me" lol.
I realized that my form data was URI encoded. I needed to change the enctype of my form.

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