2017-08-21 15:41:52 +02:00
|
|
|
if (!String.prototype.includes) {
|
|
|
|
String.prototype.includes = function(search, start) {
|
|
|
|
'use strict';
|
|
|
|
if (typeof start !== 'number') {
|
|
|
|
start = 0;
|
|
|
|
}
|
|
|
|
if (start + search.length > this.length) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return this.indexOf(search, start) !== -1; // eslint-disable-line lodash/prefer-includes
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-09-25 22:57:55 +02:00
|
|
|
if (!String.prototype.endsWith) {
|
2016-12-05 19:55:11 +01:00
|
|
|
String.prototype.endsWith = function (searchString, position) {
|
2015-09-25 22:57:55 +02:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-12-05 19:55:11 +01:00
|
|
|
if (!String.prototype.startsWith) {
|
|
|
|
String.prototype.startsWith = function (searchString, position) {
|
|
|
|
position = position || 0;
|
|
|
|
return this.substr(position, searchString.length) === searchString;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!String.prototype.splitOnce) {
|
|
|
|
String.prototype.splitOnce = function (delimiter) {
|
|
|
|
var components = this.split(delimiter);
|
|
|
|
return [components.shift(), components.join(delimiter)];
|
|
|
|
};
|
|
|
|
}
|
2015-09-25 23:03:37 +02:00
|
|
|
|
|
|
|
if (!String.prototype.trim) {
|
|
|
|
String.prototype.trim = function () {
|
|
|
|
return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
|
|
|
};
|
|
|
|
}
|