PReviously if the directory argument ended in slash, we'd get a doubled slash in the path. This may help with #7881.