raptor-util
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -6,8 +6,8 @@ var elTest = /[&<]/; | ||
var replacements = { | ||
'<': "<", | ||
'>': ">", | ||
'&': "&", | ||
'"': """, | ||
"'": "'", | ||
'\n': " " //Preserve new lines so that they don't get normalized as space | ||
'<': '<', | ||
'>': '>', | ||
'&': '&', | ||
'"': '"', | ||
'\'': ''', | ||
'\n': ' ' //Preserve new lines so that they don't get normalized as space | ||
}; | ||
@@ -20,13 +20,16 @@ | ||
function escapeXml(str) { | ||
if (typeof str === 'string' && elTest.test(str)) { | ||
return str.replace(elTestReplace, replaceChar); | ||
// check for most common case first | ||
if (typeof str === 'string') { | ||
return elTest.test(str) ? str.replace(elTestReplace, replaceChar) : str; | ||
} | ||
return str; | ||
return (str == null) ? '' : str.toString(); | ||
} | ||
function escapeXmlAttr(str) { | ||
if (typeof str === 'string' && attrTest.test(str)) { | ||
return str.replace(attrReplace, replaceChar); | ||
if (typeof str === 'string') { | ||
return attrTest.test(str) ? str.replace(attrReplace, replaceChar) : str; | ||
} | ||
return str; | ||
return (str == null) ? '' : str.toString(); | ||
} | ||
@@ -33,0 +36,0 @@ |
@@ -25,3 +25,3 @@ { | ||
}, | ||
"version": "1.0.2" | ||
"version": "1.0.3" | ||
} |
22051
578