Nodejs HTML Escape normalizeHtml()

Here you can find the source of normalizeHtml()

Method Source Code

String.prototype.normalizeHtml = function () {
    return  this.replace(/(\n|\r|\t|\s\s+)/gm, "").trim();
};

Related

  1. htmlEscape()
    String.prototype.htmlEscape = function (){
      var escapedStr = String(this).replace(/&/g, '&');
      escapedStr = escapedStr.replace(/</g, '&lt;');
      escapedStr = escapedStr.replace(/>/g, '&gt;');
      escapedStr = escapedStr.replace(/"/g, '&quot;');
      escapedStr = escapedStr.replace(/'/g, "&#39");
      return escapedStr;
    
  2. htmlEscape()
    String.prototype.htmlEscape = function() {
        return this.replace(/&/g, '&amp;')
            .replace(/</g, '&lt;')
            .replace(/>/g, '&gt;')
            .replace(/"/g, '&quot;')
            .replace(/'/g, '&#39;');
    console.log('<script>'.htmlEscape()); 
    
  3. htmlEscape()
    "use strict";
    String.prototype.htmlEscape = function()
      return this.
        replace(/&/g, '&amp;').
        replace(/</g, '&lt;').
        replace(/>/g, '&gt;').
        replace(/"/g, '&quot;').
        replace(/\n/g, '<br/>');
    ...
    
  4. htmlEscape()
    String.prototype.htmlEscape = function() {
      var obj = document.createElement('div');
      if (typeof obj.textContent != 'undefined') {
        obj.textContent = this;
      } else {
        obj.innerText = this;
      return obj.innerHTML;
    };
    ...
    
  5. htmlEscape()
    String.prototype.htmlEscape = function () {
      return this.replace(/"/g, '&quot;').replace(/>/g, '&gt;').replace(/</g, '&lt;').replace(/&/g, '&amp;');
    };