Use es6 `String.endsWith` instead of custom function