basename and dirname must be able to handle paths ending in zero or more
slashes. Concatenation of dir- and basename will otherwise go wrong in
edge cases.
previously:
dirname(foo/bar/) -> foo/bar
basename(foo/bar/) -> bar
=> foo/bar/bar
now:
dirname(foo/bar///) -> foo
basename(foo/bar///) -> bar
=> foo/bar