SERVER-8723

instead of RegExp, using lastIndexOf to calculate if string ends with
str.