Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: isaacs/minimatch
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v7.4.4
Choose a base ref
...
head repository: isaacs/minimatch
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v7.4.5
Choose a head ref
  • 4 commits
  • 7 files changed
  • 1 contributor

Commits on Apr 3, 2023

  1. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    isaacs isaacs
    Copy the full SHA
    dde9b07 View commit details
  2. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    isaacs isaacs
    Copy the full SHA
    6efe9e4 View commit details
  3. formatting

    isaacs committed Apr 3, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    isaacs isaacs
    Copy the full SHA
    ca89e3f View commit details
  4. 7.4.5

    isaacs committed Apr 3, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    isaacs isaacs
    Copy the full SHA
    d6c09b7 View commit details
Showing with 55 additions and 41 deletions.
  1. +9 −9 README.md
  2. +2 −2 changelog.md
  3. +2 −2 package-lock.json
  4. +4 −1 package.json
  5. +15 −14 src/index.ts
  6. +7 −3 test/escape-has-magic.js
  7. +16 −10 test/windows-no-magic-root.ts
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -35,8 +35,8 @@ Supports these glob features:
- [Posix character
classes](https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html),
like `[[:alpha:]]`, supporting the full range of Unicode
characters. For example, `[[:alpha:]]` will match against
`'é'`, though `[a-zA-Z]` will not. Collating symbol and set
characters. For example, `[[:alpha:]]` will match against
`'é'`, though `[a-zA-Z]` will not. Collating symbol and set
matching is not supported, so `[[=e=]]` will _not_ match `'é'`
and `[[.ch.]]` will not match `'ch'` in locales where `ch` is
considered a single character.
@@ -131,19 +131,19 @@ var mm = new Minimatch(pattern, options)
method is mainly for internal use, but is exposed so that it can be
used by a glob-walker that needs to avoid excessive filesystem calls.
- `hasMagic()` Returns true if the parsed pattern contains any
magic characters. Returns false if all comparator parts are
string literals. If the `magicalBraces` option is set on the
magic characters. Returns false if all comparator parts are
string literals. If the `magicalBraces` option is set on the
constructor, then it will consider brace expansions which are
not otherwise magical to be magic. If not set, then a pattern
not otherwise magical to be magic. If not set, then a pattern
like `a{b,c}d` will return `false`, because neither `abd` nor
`acd` contain any special glob characters.

This does **not** mean that the pattern string can be used as a
literal filename, as it may contain magic glob characters that
are escaped. For example, the pattern `\\*` or `[*]` would not
are escaped. For example, the pattern `\\*` or `[*]` would not
be considered to have magic, as the matching portion parses to
the literal string `'*'` and would match a path named `'*'`,
not `'\\*'` or `'[*]'`. The `minimatch.unescape()` method may
not `'\\*'` or `'[*]'`. The `minimatch.unescape()` method may
be used to remove escape characters.

All other methods are internal, and will be called as necessary.
@@ -182,7 +182,7 @@ be escaped or unescaped.
Un-escape a glob string that may contain some escaped characters.

If the `windowsPathsNoEscape` option is used, then square-brace
escapes are removed, but not backslash escapes. For example, it
escapes are removed, but not backslash escapes. For example, it
will turn the string `'[*]'` into `*`, but it will not turn
`'\\*'` into `'*'`, because `\` is a path separator in
`windowsPathsNoEscape` mode.
@@ -261,7 +261,7 @@ This only affects the results of the `Minimatch.hasMagic` method.

If the pattern contains brace expansions, such as `a{b,c}d`, but
no other magic characters, then the `Minipass.hasMagic()` method
will return `false` by default. When this option set, it will
will return `false` by default. When this option set, it will
return `true` for brace expansion as well as other magic glob
characters.

4 changes: 2 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -18,10 +18,10 @@

- Add `optimizationLevel` configuration option, and revert the
default back to the 6.2 style minimal optimizations, making the
advanced transforms introduced in 7.0 opt-in. Also, process
advanced transforms introduced in 7.0 opt-in. Also, process
provided file paths in the same way in optimizationLevel:2
mode, so _most_ things that matched with optimizationLevel 1 or
0 _should_ match with level 2 as well. However, level 1 is the
0 _should_ match with level 2 as well. However, level 1 is the
default, out of an abundance of caution.

## 7.0
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -2,7 +2,10 @@
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)",
"name": "minimatch",
"description": "a glob matcher in javascript",
"version": "7.4.4",
"version": "7.4.5",
"publishConfig": {
"tag": "legacy-v7"
},
"repository": {
"type": "git",
"url": "git://github.com/isaacs/minimatch.git"
29 changes: 15 additions & 14 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -3,6 +3,19 @@ import { parseClass } from './brace-expressions.js'
import { escape } from './escape.js'
import { unescape } from './unescape.js'

type Platform =
| 'aix'
| 'android'
| 'darwin'
| 'freebsd'
| 'haiku'
| 'linux'
| 'openbsd'
| 'sunos'
| 'win32'
| 'cygwin'
| 'netbsd'

export interface MinimatchOptions {
nobrace?: boolean
nocomment?: boolean
@@ -22,18 +35,7 @@ export interface MinimatchOptions {
flipNegate?: boolean
preserveMultipleSlashes?: boolean
optimizationLevel?: number
platform?:
| 'aix'
| 'android'
| 'darwin'
| 'freebsd'
| 'haiku'
| 'linux'
| 'openbsd'
| 'sunos'
| 'win32'
| 'cygwin'
| 'netbsd'
platform?: Platform
windowsNoMagicRoot?: boolean
}

@@ -106,7 +108,6 @@ const qmarksTestNoExtDot = ([$0]: RegExpMatchArray) => {
return (f: string) => f.length === len && f !== '.' && f !== '..'
}

type Platform = typeof process.platform
/* c8 ignore start */
const defaultPlatform: Platform = (
typeof process === 'object' && process
@@ -377,7 +378,7 @@ export class Minimatch {
this.make()
}

hasMagic():boolean {
hasMagic(): boolean {
if (this.options.magicalBraces && this.set.length > 1) {
return true
}
10 changes: 7 additions & 3 deletions test/escape-has-magic.js
Original file line number Diff line number Diff line change
@@ -9,9 +9,13 @@ for (const p of patterns) {
const escapep = escape(pattern)
const escapew = escape(pattern, { windowsPathsNoEscape: true })
t.equal(unescape(escapep), pattern, 'posix unescape(' + pattern + ')')
t.equal(unescape(escapew, {
windowsPathsNoEscape: true,
}), pattern, 'win32 unescape(' + pattern + ')')
t.equal(
unescape(escapew, {
windowsPathsNoEscape: true,
}),
pattern,
'win32 unescape(' + pattern + ')'
)
const mmp = new Minimatch(escapep, { ...opts, nocaseMagicOnly: true })
const mmw = new Minimatch(escapew, {
...opts,
26 changes: 16 additions & 10 deletions test/windows-no-magic-root.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Minimatch} from '../'
import { Minimatch } from '../'
import t from 'tap'

t.test('no magic the root', t => {
@@ -16,15 +16,21 @@ t.test('no magic the root', t => {
t.plan(patterns.length)
for (const p of patterns) {
t.test(p, t => {
t.matchSnapshot(new Minimatch(p, {
platform: 'win32',
nocase: true,
}).set, 'default to true')
t.matchSnapshot(new Minimatch(p, {
windowsNoMagicRoot: false,
platform: 'win32',
nocase: true,
}).set, 'set explicitly false')
t.matchSnapshot(
new Minimatch(p, {
platform: 'win32',
nocase: true,
}).set,
'default to true'
)
t.matchSnapshot(
new Minimatch(p, {
windowsNoMagicRoot: false,
platform: 'win32',
nocase: true,
}).set,
'set explicitly false'
)
t.end()
})
}