path: fix bugs related to paths with trailing slashes


Fix issue #4520

After look more closely at the `splitPath` code `path.basename` wasn't the only method there was (or would be) wrong.

* `path.extname('/file.ext/')`returned `''` (empty string). It now returns `.ext`
* `path.dirname('////')` returned `//`, it now returns '/'.
* `path.basename('/file.ext/')` returned `file.ext/`, it now returns `file.ext`.

This should be tested on windows as well, I have a license but I have never managed to compile node on windows properly. Could someone else test this?

Note: originally I had hoped to simply fix the `splitPathRe` regexp, but matching a not-fixed number of `/` at multiply positions did quickly become complicated.

/cc @bnoordhuis