string.endsWith() checks if a string ends with another string.
String.prototype.endsWith() checks if a string ends with another string.
This refactoring replaces index-based single-character comparison with
s[s.length - 1] === '/' becomes
What do I need to consider?
String.endsWith is an ES20215 feature. It is supported on all modern browsers, but for older browsers polyfilling might be required