common-urlpath-prefix
Computes the longest common base path prefix.
Usage
API:
var cup = paths = processargv opts = sep: '/' ; consoledir;consoledir;consoledir;
For details see doc/demo/usage.js
.
CLI:
$ common-urlpath-prefix $(find /usr/share/apache2/ -name '*.png')/usr/share/apache2/icons/$ CUP_SEP=. common-urlpath-prefix /etc/apparmor.d/*d/etc/apparmor.d/usr.sbin.$ CUP_SEP=. common-urlpath-prefix $(git config --list | grep rig)remote.origin.
You can use .cfg(defaultOpts)
to get a wrapper for cup()
with custom
default options:
var cupBksl = ;consoledir;
Comparison to other modules
Major differences from lcp and common-prefix:
- CUP splits at directory seperators only.
Major differences from common-path-prefix:
- CUP doesn't sort. Each original path is checked only once, and the number
of splits is limited by the current longest prefix, so complexity should
be
O(n)
. - CUP accepts URLs.
- CUP will return the full original path if only one path/URL is given or all given paths are equal.
License
ISC