Files
discourse-data-explorer/assets/javascripts/discourse/initializers/polyfill-string-endswith.js.es6
T
2015-08-25 20:48:19 -07:00

17 lines
550 B
JavaScript

export default {
name: 'polyfill-string-endswith',
initialize(container) {
if (!String.prototype.endsWith) {
String.prototype.endsWith = function(searchString, position) {
var subjectString = this.toString();
if (position === undefined || position > subjectString.length) {
position = subjectString.length;
}
position -= searchString.length;
var lastIndex = subjectString.indexOf(searchString, position);
return lastIndex !== -1 && lastIndex === position;
};
}
}
};