path: fix bugs related to paths with trailing slashes