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.1.3
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.1.4
Choose a head ref
  • 2 commits
  • 5 files changed
  • 1 contributor

Commits on Feb 26, 2023

  1. fix: need two parts following a **/.. to optimize

    If **/../p is expanded to {**,..}/p, then that means that it can match p
    even if the directory that contains p doesn't have any child directories
    to have fallen up into its parent with the ..
    
    However, if there are *two* parts following the **/.. then that means
    that **/../p/q will mean that there must have been child directories in
    p's parent, because p is a child directory in p's parent, and the
    required walking overhead is cut in half as before.
    isaacs committed Feb 26, 2023
    Copy the full SHA
    695d5da View commit details
  2. 7.1.4

    isaacs committed Feb 26, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    f050a22 View commit details
Showing with 478 additions and 19 deletions.
  1. +2 −2 package-lock.json
  2. +1 −1 package.json
  3. +17 −4 src/index.ts
  4. +452 −12 tap-snapshots/test/optimization-level-2.ts.test.cjs
  5. +6 −0 test/optimization-level-2.ts
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": "7.1.3",
"version": "7.1.4",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/minimatch.git"
21 changes: 17 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -99,7 +99,10 @@ const defaultPlatform: Platform = (
: 'posix'
) as Platform
type Sep = '\\' | '/'
const path:{[k:string]:{sep:Sep}} = { win32: { sep: '\\' }, posix: { sep: '/' } }
const path: { [k: string]: { sep: Sep } } = {
win32: { sep: '\\' },
posix: { sep: '/' },
}
/* c8 ignore stop */

export const sep = defaultPlatform === 'win32' ? path.win32.sep : path.posix.sep
@@ -538,7 +541,7 @@ export class Minimatch {
// and ** cannot be reduced out by a .. pattern part like a regexp
// or most strings (other than .., ., and '') can be.
//
// <pre>/**/../<p>/<rest> -> {<pre>/../<p>/<rest>,<pre>/**/<p>/<rest>}
// <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
// <pre>/<e>/<rest> -> <pre>/<rest>
// <pre>/<p>/../<rest> -> <pre>/<rest>
// **/**/<rest> -> **/<rest>
@@ -549,7 +552,7 @@ export class Minimatch {
let didSomething = false
do {
didSomething = false
// <pre>/**/../<p>/<rest> -> {<pre>/../<p>/<rest>,<pre>/**/<p>/<rest>}
// <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
for (let parts of globParts) {
let gs: number = -1
while (-1 !== (gs = parts.indexOf('**', gs + 1))) {
@@ -566,8 +569,18 @@ export class Minimatch {

let next = parts[gs + 1]
const p = parts[gs + 2]
const p2 = parts[gs + 3]
if (next !== '..') continue
if (!p || p === '.' || p === '..') continue
if (
!p ||
p === '.' ||
p === '..' ||
!p2 ||
p2 === '.' ||
p2 === '..'
) {
continue
}
didSomething = true
// edit parts in place, and push the new one
parts.splice(gs, 1)
Loading