Avoid another unnecessary string split
We are only interested in the last element and not the whole split list so doing a full split is inefficient.
Instead use lastIndexOf and mid.
We need to special-case when the string ends with a / since otherwise we would end up with an empty string