From 7bca18ba41ab09b6761b42baf3ed89d875ef2a5c Mon Sep 17 00:00:00 2001 From: WilliamBZA Date: Mon, 8 Jul 2019 08:01:48 +0200 Subject: [PATCH] Add polyfill for endsWith --- src/ServicePulse.Host/app/index.html | 1 + .../app/js/polyfill/string.prototype.endsWith.js | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 src/ServicePulse.Host/app/js/polyfill/string.prototype.endsWith.js diff --git a/src/ServicePulse.Host/app/index.html b/src/ServicePulse.Host/app/index.html index 5018620625..de8332194f 100644 --- a/src/ServicePulse.Host/app/index.html +++ b/src/ServicePulse.Host/app/index.html @@ -240,5 +240,6 @@

Warning!

+ diff --git a/src/ServicePulse.Host/app/js/polyfill/string.prototype.endsWith.js b/src/ServicePulse.Host/app/js/polyfill/string.prototype.endsWith.js new file mode 100644 index 0000000000..a4cde01f68 --- /dev/null +++ b/src/ServicePulse.Host/app/js/polyfill/string.prototype.endsWith.js @@ -0,0 +1,11 @@ +// Code taken from MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith#Polyfill +// which is shared using the following license: cc-by-sa 2.5 https://creativecommons.org/licenses/by-sa/2.5/ +// https://tc39.github.io/ecma262/#sec-array.prototype.find +if (!String.prototype.endsWith) { + String.prototype.endsWith = function(search, this_len) { + if (this_len === undefined || this_len > this.length) { + this_len = this.length; + } + return this.substring(this_len - search.length, this_len) === search; + }; +} \ No newline at end of file