Nodejs HTML Escape escapeHTML()

Here you can find the source of escapeHTML()

Method Source Code

String.prototype.escapeHTML = function () {
  return(this.replace(/&/g,'&amp;').replace(/>/g,'&gt;').replace(/</g,'&lt;').replace(/"/g,'&quot;'));                                                 
};

Related

  1. escapeHTML()
    String.prototype.escapeHTML = function() {
      return this.
        replace(/&/g, "&amp;").
        replace(/</g, "&lt;").
        replace(/>/g, "&gt;").
        replace(/\"/g, "&quot;");
    };
    console.log("<&>".escapeHTML()); 
    
  2. escapeHTML()
    String.prototype.escapeHTML = function(){
      var str = this.replace(/</g, '&lt;');
      return str.replace(/>/g, '&gt;');
    };
    
  3. escapeHTML()
    String.prototype.escapeHTML = function()
      var m = {"&": "&amp;", "<": "&lt;", ">": "&gt;", '"': '&quot;', "'": '&#39;', "/": '&#x2F;'};
      return String(this).replace(/[&<>"'\/]/g, function(s)
        return m[s];
      });
    
  4. escapeHTML()
    var __entityMap = {
      "&": "&amp;",
      "<": "&lt;",
      ">": "&gt;",
      '"': '&quot;',
      "'": '&#39;',
      "/": '&#x2F;'
    };
    String.prototype.escapeHTML = function() {
    ...
    
  5. escapeHTML()
    String.prototype.escapeHTML = function() {
      return this.replace(/</g,'&lt;').replace(/>/g, '&gt;');
    };
    
  6. escapeHTML()
    String.prototype.escapeHTML = function() {
      return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
    };
    
  7. escapeHTML()
    var __entityMap = {
      "&": "&amp;",
      "<": "&lt;",
      ">": "&gt;",
      '"': '&quot;',
      "'": '&#39;',
      "/": '&#x2F;'
    };
    String.prototype.escapeHTML = function() {
    ...