handle directories with trailing slashes omitted