Nodejs String Sanitize sanitize()

Here you can find the source of sanitize()

Method Source Code

String.prototype.sanitize = function() {
    return $('<div/>').text(this).html();
};

Related

  1. sanitize()
    String.prototype.sanitize = function(){
        return this.replace(/</g, '&lt;').replace(/>/g, '&gt;');
    
  2. sanitize()
    String.prototype.sanitize = function() {
      return this
        .replace(/&/g, '&amp;')
        .replace(/</g, '&lt;')
        .replace(/>/g, '&gt;')
        .replace(/"/g, '&quot;')
        .replace(/'/g, '&#39;')
    
  3. sanitize()
    String.prototype.sanitize = function () {
        var str = this.replace(/<[^>]*?>/g, '');
        return str;
    };
    
  4. sanitizeSpacing()
    "use strict";
    String.prototype.sanitizeSpacing = function () {
        return this
            .replace(/[\t\r\n\-]/g, ' ')  
            .replace(/  +/g, ' ')          
            .trim();                       
    };