diff --git a/app/assets/javascripts/polyfills.js b/app/assets/javascripts/polyfills.js index 71ced4c904e..93b18ae9ec0 100644 --- a/app/assets/javascripts/polyfills.js +++ b/app/assets/javascripts/polyfills.js @@ -94,4 +94,21 @@ if (!Array.prototype.includes) { } }); } + +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes#Polyfill +if (!String.prototype.includes) { + Object.defineProperty(String.prototype, 'includes', { + value: function(search, start) { + if (typeof start !== 'number') { + start = 0 + } + + if (start + search.length > this.length) { + return false + } else { + return this.indexOf(search, start) !== -1 + } + } + }) +} /* eslint-enable */