treat last *non-zero* segment as basename

- for paths like "foo/", basename should be "foo"

fixes #12