Detects the same starting part of the path in an array of file paths.
npm install common-path-start



Detects the same starting part of the path in an array of file paths and returns it, its length, or it cuts it from the specified file paths.
If you have the following file paths:
``text`
snapshots/fun/hmpg.net.html
snapshots/fun/xkcd.com.html
snapshots/wikimedia.org.html
This plugin lets you detects "snapshots/" as the common path start, its length 10 characters, or cut the common start from every file path producing:
`text`
fun/hmpg.net.html
fun/xkcd.com.html
wikimedia.org.html
You need [node >= 6][node] and [npm] installed. You may install this module with the following command:
`sh`
$ npm install common-path-start --save
This module exports several static functions operating on file paths, which use forward slash as a separator.
`js``
const {getCommonPathStart} = require('common-path-start')
const paths = [
'snapshots/fun/hmpg.net.html',
'snapshots/fun/xkcd.com.html',
'snapshots/wikimedia.org.html'
]
const commonPathStart = getCommonPathStart(paths) // "snapshots/"
Expects an array of strings with file paths and returns a string with the common path start, or an empty string, if there is no common starting directory among all file paths.
Expects an array of strings with file paths and returns the count of characters of the common path start, or zero, if there is no common starting directory among all file paths.
Expects an array of strings with file paths and returns a new array with file paths with the common path start cut away, or the same file path array, if there is no common starting directory among all file paths.
In lieu of a formal styleguide, take care to maintain the existing coding style.
* 2018-05-14 v0.0.1 Initial release
Copyright (c) 2018-2019 Ferdinand Prantl
Licensed under the MIT license.
[node]: http://nodejs.org
[npm]: http://npmjs.org