From ae92f541222509267f208b7b74e2864a78bbc725 Mon Sep 17 00:00:00 2001 From: printempw Date: Mon, 26 Sep 2016 22:36:34 +0800 Subject: [PATCH] fix compatibility of String.prototype.endsWith --- resources/assets/src/js/utils.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/resources/assets/src/js/utils.js b/resources/assets/src/js/utils.js index d453b766..8d406829 100644 --- a/resources/assets/src/js/utils.js +++ b/resources/assets/src/js/utils.js @@ -2,7 +2,7 @@ * @Author: printempw * @Date: 2016-07-16 09:02:32 * @Last Modified by: printempw - * @Last Modified time: 2016-09-24 18:10:03 + * @Last Modified time: 2016-09-26 22:35:35 */ $.locales = {}; @@ -145,3 +145,16 @@ function getQueryString(key) { return result[1]; } } + +// quick fix for compatibility of String.prototype.endsWith +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; + }; +}