fix issue with endsWith not working in all browsers