blob: 8e141babc47a79ad5d2552e54239a881886d0aef [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001/*!
2 * path-root <https://github.com/jonschlinkert/path-root>
3 *
4 * Copyright (c) 2016, Jon Schlinkert.
5 * Licensed under the MIT License.
6 */
7
8'use strict';
9
10var pathRootRegex = require('path-root-regex');
11
12module.exports = function(filepath) {
13 if (typeof filepath !== 'string') {
14 throw new TypeError('expected a string');
15 }
16
17 var match = pathRootRegex().exec(filepath);
18 if (match) {
19 return match[0];
20 }
21};