Computes the longest prefix string that is common to each path, excluding the base component
Installations
npm install common-path-prefix
Developer
novemberborn
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
No
Node Version
12.13.0
NPM Version
6.12.1
Statistics
10 Stars
44 Commits
3 Forks
2 Watching
1 Branches
4 Contributors
Updated on 01 Jul 2023
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
955,101,672
Last day
-5.4%
1,594,525
Compared to previous day
Last week
2.7%
8,875,678
Compared to previous week
Last month
6.1%
37,321,186
Compared to previous month
Last year
32%
418,781,695
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
common-path-prefix
Computes the longest prefix string that is common to each path, excluding the base component. Tested with Node.js 8 and above.
Installation
1npm install common-path-prefix
Usage
The module has one default export, the commonPathPrefix
function:
1const commonPathPrefix = require('common-path-prefix')
Call commonPathPrefix()
with an array of paths (strings) and an optional separator character:
1const paths = ['templates/main.handlebars', 'templates/_partial.handlebars'] 2 3commonPathPrefix(paths, '/') // returns 'templates/'
If the separator is not provided the first /
or \
found in any of the paths is used. Otherwise the platform-default value is used:
1commonPathPrefix(['templates/main.handlebars', 'templates/_partial.handlebars']) // returns 'templates/'
2commonPathPrefix(['templates\\main.handlebars', 'templates\\_partial.handlebars']) // returns 'templates\\'
You can provide any separator, for example:
1commonPathPrefix(['foo$bar', 'foo$baz'], '$') // returns 'foo$''
An empty string is returned if no common prefix exists:
1commonPathPrefix(['foo/bar', 'baz/qux']) // returns '' 2commonPathPrefix(['foo/bar']) // returns ''
Note that the following does have a common prefix:
1commonPathPrefix(['/foo/bar', '/baz/qux']) // returns '/'
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: ISC License: LICENSE:0
Reason
Found 10/25 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 18 are checked with a SAST tool
Score
3.6
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More