Files
asciidisco.com/build/node_modules/xml/lib/escapeForXML.js
2023-08-01 13:49:46 +02:00

19 lines
358 B
JavaScript

var XML_CHARACTER_MAP = {
'&': '&',
'"': '"',
"'": ''',
'<': '&lt;',
'>': '&gt;'
};
function escapeForXML(string) {
return string && string.replace
? string.replace(/([&"<>'])/g, function(str, item) {
return XML_CHARACTER_MAP[item];
})
: string;
}
module.exports = escapeForXML;