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: v6.1.8
Choose a base ref
...
head repository: isaacs/minimatch
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v6.1.9
Choose a head ref
  • 2 commits
  • 5 files changed
  • 1 contributor

Commits on Feb 13, 2023

  1. Copy the full SHA
    8c42d42 View commit details
  2. 6.1.9

    isaacs committed Feb 13, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    a26fe30 View commit details
Showing with 38 additions and 5 deletions.
  1. +2 −2 package-lock.json
  2. +1 −1 package.json
  3. +12 −2 src/index.ts
  4. +12 −0 tap-snapshots/test/basic.js.test.cjs
  5. +11 −0 test/patterns.js
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.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)",
"name": "minimatch",
"description": "a glob matcher in javascript",
"version": "6.1.8",
"version": "6.1.9",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/minimatch.git"
14 changes: 12 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -382,6 +382,8 @@ export class Minimatch {
// ** is * anyway
this.globParts = rawGlobParts
} else {
// do this swap BEFORE the reduce, so that we can turn a string
// of **/*/**/* into */*/**/** and then reduce the **'s into one
for (const parts of rawGlobParts) {
let swapped: boolean
do {
@@ -397,9 +399,17 @@ export class Minimatch {
}
this.globParts = rawGlobParts.map(parts =>
parts.reduce((set: string[], part) => {
if (part !== '**' || set[set.length - 1] !== '**') {
set.push(part)
const prev = set[set.length - 1]
if (part === '**' && prev === '**') {
return set
}
if (part === '..') {
if (prev && prev !== '..' && prev !== '.' && prev !== '**') {
set.pop()
return set
}
}
set.push(part)
return set
}, [])
)
12 changes: 12 additions & 0 deletions tap-snapshots/test/basic.js.test.cjs
Original file line number Diff line number Diff line change
@@ -597,6 +597,18 @@ exports[`test/basic.js TAP basic tests > makeRe s/\\..*// 1`] = `
/^(?:s\\/(?=.)\\.\\.[^/]*?\\/)$/
`

exports[`test/basic.js TAP basic tests > makeRe x/*/../../a/b/c 1`] = `
/^(?:a\\/b\\/c)$/
`

exports[`test/basic.js TAP basic tests > makeRe x/*/../a/b/c 1`] = `
/^(?:x\\/a\\/b\\/c)$/
`

exports[`test/basic.js TAP basic tests > makeRe x/z/../*/a/b/c 1`] = `
/^(?:x\\/(?!\\.)(?=.)[^/]*?\\/a\\/b\\/c)$/
`

exports[`test/basic.js TAP basic tests > makeRe {/*,*} 1`] = `
/^(?:\\/(?!\\.)(?=.)[^/]*?|(?!\\.)(?=.)[^/]*?)$/
`
11 changes: 11 additions & 0 deletions test/patterns.js
Original file line number Diff line number Diff line change
@@ -408,6 +408,17 @@ module.exports = [
['.a', '.a.js', '.js', 'a', 'a.js', 'js', 'a.JS', '.a.JS', '.JS', 'JS'],
{ dot: true },
],

() => (files = [
'x/y/z/a/b/c',
'x/y/a/b/c',
'x/z/a/b/c',
'x/a/b/c',
'a/b/c',
]),
['x/*/../a/b/c', ['x/a/b/c']],
['x/z/../*/a/b/c', ['x/y/a/b/c', 'x/z/a/b/c']],
['x/*/../../a/b/c', ['a/b/c']],
]

Object.defineProperty(module.exports, 'files', {