Test migration to jest by hand
Apparently using regular expressions is way easier.
This commit is contained in:
13
test/escapeHTML/escapeHTML.js
Normal file
13
test/escapeHTML/escapeHTML.js
Normal file
@ -0,0 +1,13 @@
|
||||
const escapeHTML = str =>
|
||||
str.replace(
|
||||
/[&<>'"]/g,
|
||||
tag =>
|
||||
({
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
"'": ''',
|
||||
'"': '"'
|
||||
}[tag] || tag)
|
||||
);
|
||||
module.exports = escapeHTML;
|
||||
Reference in New Issue
Block a user