mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
17 lines
325 B
JavaScript
17 lines
325 B
JavaScript
var XML_CHARACTER_MAP = {
|
|
'&': '&',
|
|
'"': '"',
|
|
"'": ''',
|
|
'<': '<',
|
|
'>': '>'
|
|
};
|
|
|
|
function escapeForXML(string) {
|
|
return string && string.replace
|
|
? string.replace(/([&"<>'])/g, function (str, item) {
|
|
return XML_CHARACTER_MAP[item];
|
|
})
|
|
: string;
|
|
}
|
|
|
|
module.exports = escapeForXML; |