escape-attribute.js 320 B

12345678910111213
  1. /**
  2. * Escapes characters that can not be in an XML attribute.
  3. */
  4. function escapeAttribute(value) {
  5. return value.replace(/&/g, '&amp;').replace(/'/g, '&apos;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
  6. }
  7. /**
  8. * @api private
  9. */
  10. module.exports = {
  11. escapeAttribute: escapeAttribute
  12. };