source: frontend/node_modules/minimatch/README.md

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 8.5 KB
Line 
1# minimatch
2
3A minimal matching utility.
4
5[![Build Status](https://travis-ci.org/isaacs/minimatch.svg?branch=master)](http://travis-ci.org/isaacs/minimatch)
6
7
8This is the matching library used internally by npm.
9
10It works by converting glob expressions into JavaScript `RegExp`
11objects.
12
13## Important Security Consideration!
14
15> [!WARNING]
16> This library uses JavaScript regular expressions. Please read
17> the following warning carefully, and be thoughtful about what
18> you provide to this library in production systems.
19
20_Any_ library in JavaScript that deals with matching string
21patterns using regular expressions will be subject to
22[ReDoS](https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS)
23if the pattern is generated using untrusted input.
24
25Efforts have been made to mitigate risk as much as is feasible in
26such a library, providing maximum recursion depths and so forth,
27but these measures can only ultimately protect against accidents,
28not malice. A dedicated attacker can _always_ find patterns that
29cannot be defended against by a bash-compatible glob pattern
30matching system that uses JavaScript regular expressions.
31
32To be extremely clear:
33
34> [!WARNING]
35> **If you create a system where you take user input, and use
36> that input as the source of a Regular Expression pattern, in
37> this or any extant glob matcher in JavaScript, you will be
38> pwned.**
39
40A future version of this library _may_ use a different matching
41algorithm which does not exhibit backtracking problems. If and
42when that happens, it will likely be a sweeping change, and those
43improvements will **not** be backported to legacy versions.
44
45In the near term, it is not reasonable to continue to play
46whack-a-mole with security advisories, and so any future ReDoS
47reports will be considered "working as intended", and resolved
48entirely by this warning.
49
50## Usage
51
52```javascript
53var minimatch = require("minimatch")
54
55minimatch("bar.foo", "*.foo") // true!
56minimatch("bar.foo", "*.bar") // false!
57minimatch("bar.foo", "*.+(bar|foo)", { debug: true }) // true, and noisy!
58```
59
60## Features
61
62Supports these glob features:
63
64* Brace Expansion
65* Extended glob matching
66* "Globstar" `**` matching
67
68See:
69
70* `man sh`
71* `man bash`
72* `man 3 fnmatch`
73* `man 5 gitignore`
74
75## Minimatch Class
76
77Create a minimatch object by instantiating the `minimatch.Minimatch` class.
78
79```javascript
80var Minimatch = require("minimatch").Minimatch
81var mm = new Minimatch(pattern, options)
82```
83
84### Properties
85
86* `pattern` The original pattern the minimatch object represents.
87* `options` The options supplied to the constructor.
88* `set` A 2-dimensional array of regexp or string expressions.
89 Each row in the
90 array corresponds to a brace-expanded pattern. Each item in the row
91 corresponds to a single path-part. For example, the pattern
92 `{a,b/c}/d` would expand to a set of patterns like:
93
94 [ [ a, d ]
95 , [ b, c, d ] ]
96
97 If a portion of the pattern doesn't have any "magic" in it
98 (that is, it's something like `"foo"` rather than `fo*o?`), then it
99 will be left as a string rather than converted to a regular
100 expression.
101
102* `regexp` Created by the `makeRe` method. A single regular expression
103 expressing the entire pattern. This is useful in cases where you wish
104 to use the pattern somewhat like `fnmatch(3)` with `FNM_PATH` enabled.
105* `negate` True if the pattern is negated.
106* `comment` True if the pattern is a comment.
107* `empty` True if the pattern is `""`.
108
109### Methods
110
111* `makeRe` Generate the `regexp` member if necessary, and return it.
112 Will return `false` if the pattern is invalid.
113* `match(fname)` Return true if the filename matches the pattern, or
114 false otherwise.
115* `matchOne(fileArray, patternArray, partial)` Take a `/`-split
116 filename, and match it against a single row in the `regExpSet`. This
117 method is mainly for internal use, but is exposed so that it can be
118 used by a glob-walker that needs to avoid excessive filesystem calls.
119
120All other methods are internal, and will be called as necessary.
121
122### minimatch(path, pattern, options)
123
124Main export. Tests a path against the pattern using the options.
125
126```javascript
127var isJS = minimatch(file, "*.js", { matchBase: true })
128```
129
130### minimatch.filter(pattern, options)
131
132Returns a function that tests its
133supplied argument, suitable for use with `Array.filter`. Example:
134
135```javascript
136var javascripts = fileList.filter(minimatch.filter("*.js", {matchBase: true}))
137```
138
139### minimatch.match(list, pattern, options)
140
141Match against the list of
142files, in the style of fnmatch or glob. If nothing is matched, and
143options.nonull is set, then return a list containing the pattern itself.
144
145```javascript
146var javascripts = minimatch.match(fileList, "*.js", {matchBase: true}))
147```
148
149### minimatch.makeRe(pattern, options)
150
151Make a regular expression object from the pattern.
152
153## Options
154
155All options are `false` by default.
156
157### debug
158
159Dump a ton of stuff to stderr.
160
161### nobrace
162
163Do not expand `{a,b}` and `{1..3}` brace sets.
164
165### noglobstar
166
167Disable `**` matching against multiple folder names.
168
169### dot
170
171Allow patterns to match filenames starting with a period, even if
172the pattern does not explicitly have a period in that spot.
173
174Note that by default, `a/**/b` will **not** match `a/.d/b`, unless `dot`
175is set.
176
177### noext
178
179Disable "extglob" style patterns like `+(a|b)`.
180
181### nocase
182
183Perform a case-insensitive match.
184
185### nonull
186
187When a match is not found by `minimatch.match`, return a list containing
188the pattern itself if this option is set. When not set, an empty list
189is returned if there are no matches.
190
191### matchBase
192
193If set, then patterns without slashes will be matched
194against the basename of the path if it contains slashes. For example,
195`a?b` would match the path `/xyz/123/acb`, but not `/xyz/acb/123`.
196
197### nocomment
198
199Suppress the behavior of treating `#` at the start of a pattern as a
200comment.
201
202### nonegate
203
204Suppress the behavior of treating a leading `!` character as negation.
205
206### flipNegate
207
208Returns from negate expressions the same as if they were not negated.
209(Ie, true on a hit, false on a miss.)
210
211### partial
212
213Compare a partial path to a pattern. As long as the parts of the path that
214are present are not contradicted by the pattern, it will be treated as a
215match. This is useful in applications where you're walking through a
216folder structure, and don't yet have the full path, but want to ensure that
217you do not walk down paths that can never be a match.
218
219For example,
220
221```js
222minimatch('/a/b', '/a/*/c/d', { partial: true }) // true, might be /a/b/c/d
223minimatch('/a/b', '/**/d', { partial: true }) // true, might be /a/b/.../d
224minimatch('/x/y/z', '/a/**/z', { partial: true }) // false, because x !== a
225```
226
227### allowWindowsEscape
228
229Windows path separator `\` is by default converted to `/`, which
230prohibits the usage of `\` as a escape character. This flag skips that
231behavior and allows using the escape character.
232
233## Comparisons to other fnmatch/glob implementations
234
235While strict compliance with the existing standards is a worthwhile
236goal, some discrepancies exist between minimatch and other
237implementations, and are intentional.
238
239If the pattern starts with a `!` character, then it is negated. Set the
240`nonegate` flag to suppress this behavior, and treat leading `!`
241characters normally. This is perhaps relevant if you wish to start the
242pattern with a negative extglob pattern like `!(a|B)`. Multiple `!`
243characters at the start of a pattern will negate the pattern multiple
244times.
245
246If a pattern starts with `#`, then it is treated as a comment, and
247will not match anything. Use `\#` to match a literal `#` at the
248start of a line, or set the `nocomment` flag to suppress this behavior.
249
250The double-star character `**` is supported by default, unless the
251`noglobstar` flag is set. This is supported in the manner of bsdglob
252and bash 4.1, where `**` only has special significance if it is the only
253thing in a path part. That is, `a/**/b` will match `a/x/y/b`, but
254`a/**b` will not.
255
256If an escaped pattern has no matches, and the `nonull` flag is set,
257then minimatch.match returns the pattern as-provided, rather than
258interpreting the character escapes. For example,
259`minimatch.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than
260`"*a?"`. This is akin to setting the `nullglob` option in bash, except
261that it does not resolve escaped pattern characters.
262
263If brace expansion is not disabled, then it is performed before any
264other interpretation of the glob pattern. Thus, a pattern like
265`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded
266**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are
267checked for validity. Since those two are valid, matching proceeds.
Note: See TracBrowser for help on using the repository browser.