Skip to content

Commit 7bca18b

Browse files
committed
Add polyfill for endsWith
1 parent deb8e1b commit 7bca18b

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/ServicePulse.Host/app/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,5 +240,6 @@ <h4>Warning!</h4>
240240

241241
<!--Polyfills-->
242242
<script src="js/polyfill/array.prototype.find.js"></script>
243+
<script src="js/polyfill/string.prototype.endsWith.js"></script>
243244
</body>
244245
</html>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Code taken from MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith#Polyfill
2+
// which is shared using the following license: cc-by-sa 2.5 https://creativecommons.org/licenses/by-sa/2.5/
3+
// https://tc39.github.io/ecma262/#sec-array.prototype.find
4+
if (!String.prototype.endsWith) {
5+
String.prototype.endsWith = function(search, this_len) {
6+
if (this_len === undefined || this_len > this.length) {
7+
this_len = this.length;
8+
}
9+
return this.substring(this_len - search.length, this_len) === search;
10+
};
11+
}

0 commit comments

Comments
 (0)