Fix path.getrelative() when trailing slashes are present