fix incorrect path calculation for paths with trailing slashes