Replace String.prototype.endsWith with String.prototype.indexOf

endsWith is not yet a standard