Fix bug with name retrieval in case of trailing slash