now you're checking for directory, but you're not checking if the path-spec begins with `~`