Finds if data ends with str

@param {String} data The text to search
@param {String} str The text to find
@returns {Boolean} whether data ends with str
function endsWith(data, str) {
    if (data.length < str.length) return false;
    if (data === str) return true;
    return data.lastIndexOf(str) === data.length - str.length;
}