diff --git a/program/js/common.js b/program/js/common.js index 2abc594f9..088613d11 100644 --- a/program/js/common.js +++ b/program/js/common.js @@ -610,6 +610,18 @@ if (!String.prototype.startsWith) { }; } +if (!String.prototype.endsWith) { + String.prototype.endsWith = function(searchString, position) { + var subjectString = this.toString(); + if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) { + position = subjectString.length; + } + position -= searchString.length; + var lastIndex = subjectString.lastIndexOf(searchString, position); + return lastIndex !== -1 && lastIndex === position; + }; +} + // array utility function jQuery.last = function(arr) { return arr && arr.length ? arr[arr.length-1] : undefined;