1 # path-root [![NPM version](https://img.shields.io/npm/v/path-root.svg?style=flat)](https://www.npmjs.com/package/path-root) [![NPM downloads](https://img.shields.io/npm/dm/path-root.svg?style=flat)](https://npmjs.org/package/path-root) [![Build Status](https://img.shields.io/travis/jonschlinkert/path-root.svg?style=flat)](https://travis-ci.org/jonschlinkert/path-root)
3 > Get the root of a posix or windows filepath.
5 You might also be interested in [parse-filepath](https://github.com/jonschlinkert/parse-filepath).
9 Install with [npm](https://www.npmjs.com/):
12 $ npm install path-root --save
18 var pathRoot = require('path-root');
24 pathRoot('\\\\server\\share\\abc');
25 //=> '\\\\server\\share\\'
27 pathRoot('\\\\server foo\\some folder\\base-file.js');
28 //=> '\\\\server foo\\some folder\\'
30 pathRoot('\\\\?\\UNC\\server\\share');
33 pathRoot('foo/bar/baz.js');
36 pathRoot('c:\\foo\\bar\\baz.js');
39 pathRoot('\\\\slslslsl\\admin$\\system32');
40 //=> '\\\\slslslsl\\admin$\\'
42 pathRoot('/foo/bar/baz.js');
48 You might also be interested in these projects:
50 * [is-absolute](https://www.npmjs.com/package/is-absolute): Polyfill for node.js `path.isAbolute`. Returns true if a file path is absolute. | [homepage](https://github.com/jonschlinkert/is-absolute)
51 * [parse-filepath](https://www.npmjs.com/package/parse-filepath): Parse a filepath into an object. Falls back on the native node.js `path.parse` method if… [more](https://www.npmjs.com/package/parse-filepath) | [homepage](https://github.com/jonschlinkert/parse-filepath)
52 * [path-root-regex](https://www.npmjs.com/package/path-root-regex): Regular expression for getting the root of a posix or windows filepath. | [homepage](https://github.com/regexhq/path-root-regex)
56 Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/path-root/issues/new).
60 Generate readme and API documentation with [verb](https://github.com/verbose/verb):
63 $ npm install verb && npm run docs
66 Or, if [verb](https://github.com/verbose/verb) is installed globally:
74 Install dev dependencies:
77 $ npm install -d && npm test
84 * [github/jonschlinkert](https://github.com/jonschlinkert)
85 * [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
89 Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
90 Released under the [MIT license](https://github.com/jonschlinkert/path-root/blob/master/LICENSE).
94 _This file was generated by [verb](https://github.com/verbose/verb), v, on March 29, 2016._