Fix how trailing slashes are removed from dir names