You should maybe use path.dirname(path) instead: http://nodejs.org/api/path.html#path_path_dirname_p

We are going to allow deeper summary in gitbook so we need to prepare to handle this case.