Skip to content

Commit

Permalink
Endswith polyfill closes chrisdiana#5
Browse files Browse the repository at this point in the history
  • Loading branch information
ButuzGOL committed Jan 30, 2016
1 parent 0fac37c commit 1cb1577
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ <h1 class="post-title"></h1>
</script>

<script src="//code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="js/marked.js"></script>
<script src="js/lib/endswith-polyfill.js"></script>
<script src="js/lib/marked.js"></script>
<script src="js/cms.js"></script>
<script src="js/config.js"></script>
</body>
</html>
</html>
11 changes: 11 additions & 0 deletions js/lib/endswith-polyfill.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
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.indexOf(searchString, position);
return lastIndex !== -1 && lastIndex === position;
};
}
File renamed without changes.

0 comments on commit 1cb1577

Please sign in to comment.