| Leo Repp | 58b9f11 | 2021-11-22 11:57:47 +0100 | [diff] [blame^] | 1 | /*! |
| 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 | |||||
| 10 | var pathRootRegex = require('path-root-regex'); | ||||
| 11 | |||||
| 12 | module.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 | }; | ||||