# all files / diagram-js/lib/util/ EscapeUtil.js

25% Statements 1/4
0% Branches 0/2
0% Functions 0/2
25% Lines 1/4

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20

    1×

     export {
      default as escapeCSS
    } from 'css.escape';

    var HTML_ESCAPE_MAP = {
      '&': '&amp;',
      '<': '&lt;',
      '>': '&gt;',
      '"': '&quot;',
      '\'': '&#39;'
    };

    export function escapeHTML(str) {
      str = '' + str;

      return str && str.replace(/[&<>"']/g, function(match) {
        return HTML_ESCAPE_MAP[match];
      });
    }