Skip to content

Instantly share code, notes, and snippets.

@psynewave
Created August 25, 2020 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psynewave/59909098ee9848c7ce1023a082cb1c1b to your computer and use it in GitHub Desktop.
Save psynewave/59909098ee9848c7ce1023a082cb1c1b to your computer and use it in GitHub Desktop.
Unescape escaped HTML characters.
const unescapeHTML = str =>
str.replace(
/&|<|>|'|"/g,
tag =>
({
'&': '&',
'&lt;': '<',
'&gt;': '>',
'&#39;': "'",
'&quot;': '"'
}[tag] || tag)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment