deal with trailing slashes in directory