Created
August 25, 2020 19:02
-
-
Save psynewave/59909098ee9848c7ce1023a082cb1c1b to your computer and use it in GitHub Desktop.
Unescape escaped HTML characters.
This file contains 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 unescapeHTML = str => | |
str.replace( | |
/&|<|>|'|"/g, | |
tag => | |
({ | |
'&': '&', | |
'<': '<', | |
'>': '>', | |
''': "'", | |
'"': '"' | |
}[tag] || tag) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment