Nodejs String Ends With endsWith(suffix)

Here you can find the source of endsWith(suffix)

Method Source Code

// Generally useful stuff

String.prototype.endsWith = function(suffix) {
        return this.indexOf(suffix, this.length - suffix.length) !== -1;
};

// source: http://stackoverflow.com/a/8498629
function urlDomain(url) {
    var matches = url.match(/^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i);
    return matches[1];
}

// source: https://gist.github.com/panzi/1857360
var XML_CHAR_MAP = {
    '<': '&lt;',
    '>': '&gt;',
    '&': '&amp;',
    '"': '&quot;',
    "'": '&apos;'
}; function escapeXml (s) {
    return s.replace(/[<>&"']/g, function (ch) {
        return XML_CHAR_MAP[ch];
    });// w  ww .  j  a va  2s.c  om
} var HTML_CHAR_MAP = {
    '<': '&lt;',
    '>': '&gt;',
    '&': '&amp;',
    '"': '&quot;',
    "'": '&#39;'
}; function escapeHtml (s) {
    return s.replace(/[<>&"']/g, function (ch) {
        return HTML_CHAR_MAP[ch];
    });
}

Related

  1. endsWith(suffix)
    var path = require('path')
    String.prototype.endsWith = function(suffix) {
        return this.indexOf(suffix, this.length - suffix.length) !== -1;
    };
    module.exports = function(){
      return function drafts(files, metalsmith, done){
        Object.keys(files).forEach(function(file) {
          if (file.endsWith('.html')) {
            var baseFilename = path.basename(file)
    ...
    
  2. endsWith(suffix)
    String.prototype.endsWith = function(suffix) {
        return this.indexOf(suffix, this.length - suffix.length) !== -1;
    };
    String.prototype.startsWith = function(searchString, position) {
      position = position || 0;
      return this.indexOf(searchString, position) === position;
    };
    
  3. endsWith(suffix)
    String.prototype.endsWith = function (suffix){ 
        return this.indexOf(suffix, this.length - suffix.length) !== -1;
    };
    
  4. endsWith(suffix)
    String.prototype.endsWith = String.prototype.endsWith || function (suffix){ 
        return this.indexOf(suffix, this.length - suffix.length) !== -1;
    };
    
  5. endsWith(suffix)
    function randInRange(lo, hi) {
     if (hi === undefined) {
       hi = lo;
       lo = 0;
     return parseInt(Math.random() * (hi - lo)) + lo;
    function swap (arr, i, j) {
      var temp = arr[i];
    ...
    
  6. endsWith(suffix)
    String.prototype.endsWith = function(suffix) {
        return this.indexOf(suffix, this.length - suffix.length) !== -1;
    };
    
  7. endsWith(suffix)
    String.prototype.endsWith = function (suffix) {
      if (this.length < suffix.length)
        return false;
      return this.lastIndexOf(suffix) === this.length - suffix.length;
    };
    
  8. endsWith(suffix)
    String.prototype.endsWith = function(suffix) {
        return this.indexOf(suffix, this.length - suffix.length) !== -1;
    };
    
  9. endsWith(suffix)
    String.prototype.endsWith = function(suffix) {
        return this.indexOf(suffix, this.length - suffix.length) !== -1;
    };
    String.prototype.replaceAll = function (replaceThis, withThis) {
        var re = new RegExp(replaceThis,"g");
        return this.replace(re, withThis);
    };