When resoling url, make sure that the last / is removed only when necessary