Gathering detailed insights and metrics for @snyk/glob-parent
Gathering detailed insights and metrics for @snyk/glob-parent
Gathering detailed insights and metrics for @snyk/glob-parent
Gathering detailed insights and metrics for @snyk/glob-parent
Extract the non-magic parent path from a glob string.
npm install @snyk/glob-parent
Typescript
Module System
Min. Node Version
Node Version
NPM Version
77.8
Supply Chain
97.3
Quality
74.9
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
ISC License
80 Stars
89 Commits
45 Forks
14 Watchers
2 Branches
11 Contributors
Updated on Dec 07, 2024
Latest Version
5.1.2-patch.1
Package Id
@snyk/glob-parent@5.1.2-patch.1
Size
4.69 kB
NPM Version
6.14.8
Node Version
12.20.0
Published on
Feb 25, 2021
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Extract the non-magic parent path from a glob string.
1var globParent = require('glob-parent'); 2 3globParent('path/to/*.js'); // 'path/to' 4globParent('/root/path/to/*.js'); // '/root/path/to' 5globParent('/*.js'); // '/' 6globParent('*.js'); // '.' 7globParent('**/*.js'); // '.' 8globParent('path/{to,from}'); // 'path' 9globParent('path/!(to|from)'); // 'path' 10globParent('path/?(to|from)'); // 'path' 11globParent('path/+(to|from)'); // 'path' 12globParent('path/*(to|from)'); // 'path' 13globParent('path/@(to|from)'); // 'path' 14globParent('path/**/*'); // 'path' 15 16// if provided a non-glob path, returns the nearest dir 17globParent('path/foo/bar.js'); // 'path/foo' 18globParent('path/foo/'); // 'path/foo' 19globParent('path/foo'); // 'path' (see issue #3 for details)
globParent(maybeGlobString, [options])
Takes a string and returns the part of the path before the glob begins. Be aware of Escaping rules and Limitations below.
1{ 2 // Disables the automatic conversion of slashes for Windows 3 flipBackslashes: true 4}
The following characters have special significance in glob patterns and must be escaped if you want them to be treated as regular path characters:
?
(question mark) unless used as a path segment alone*
(asterisk)|
(pipe)(
(opening parenthesis))
(closing parenthesis){
(opening curly brace)}
(closing curly brace)[
(opening bracket)]
(closing bracket)Example
1globParent('foo/[bar]/') // 'foo' 2globParent('foo/\\[bar]/') // 'foo/[bar]'
This library attempts a quick and imperfect method of determining which path parts have glob magic without fully parsing/lexing the pattern. There are some advanced use cases that can trip it up, such as nested braces where the outer pair is escaped and the inner one contains a path separator. If you find yourself in the unlikely circumstance of being affected by this or need to ensure higher-fidelity glob handling in your library, it is recommended that you pre-process your input with expand-braces and/or expand-brackets.
Backslashes are not valid path separators for globs. If a path with backslashes is provided anyway, for simple cases, glob-parent will replace the path separator for you and return the non-glob parent path (now with forward-slashes, which are still valid as Windows path separators).
This cannot be used in conjunction with escape characters.
1// BAD 2globParent('C:\\Program Files \\(x86\\)\\*.ext') // 'C:/Program Files /(x86/)' 3 4// GOOD 5globParent('C:/Program Files\\(x86\\)/*.ext') // 'C:/Program Files (x86)'
If you are using escape characters for a pattern without path parts (i.e.
relative to cwd
), prefix with ./
to avoid confusing glob-parent.
1// BAD 2globParent('foo \\[bar]') // 'foo ' 3globParent('foo \\[bar]*') // 'foo ' 4 5// GOOD 6globParent('./foo \\[bar]') // 'foo [bar]' 7globParent('./foo \\[bar]*') // '.'
ISC
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
Found 6/27 approved changesets -- score normalized to 2
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
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