Last active
March 29, 2016 14:30
-
-
Save jamescostian/34a1e82d5f23c42a87ce to your computer and use it in GitHub Desktop.
This is like PHP's htmlentities, but for JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const htmlEntities = (str) => String(str) | |
| .replace(/&/g, '&') | |
| .replace(/</g, '<') | |
| .replace(/>/g, '>') | |
| .replace(/"/g, '"') | |
| .replace(/'/g, ''') | |
| const unhtmlEntities = (str) => String(str) | |
| .replace(/&/g, '&') | |
| .replace(/</g, '<') | |
| .replace(/>/g, '>') | |
| .replace(/"/g, '"') | |
| .replace(/'/g, "'") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment