Merge pull request #3521 from github/dependabot/npm_and_yarn/minimatch-3.1.5

Bump minimatch from 3.1.3 to 3.1.5
This commit is contained in:
Henry Mercer
2026-02-27 13:57:06 +00:00
committed by GitHub
13 changed files with 3448 additions and 933 deletions
+137 -39
View File
@@ -49512,6 +49512,7 @@ var require_minimatch = __commonJS({
pattern = pattern.split(path17.sep).join("/");
}
this.options = options;
this.maxGlobstarRecursion = options.maxGlobstarRecursion !== void 0 ? options.maxGlobstarRecursion : 200;
this.set = [];
this.pattern = pattern;
this.regexp = null;
@@ -49908,50 +49909,147 @@ var require_minimatch = __commonJS({
return this.negate;
};
Minimatch.prototype.matchOne = function(file, pattern, partial) {
var options = this.options;
this.debug(
"matchOne",
{ "this": this, file, pattern }
if (pattern.indexOf(GLOBSTAR) !== -1) {
return this._matchGlobstar(file, pattern, partial, 0, 0);
}
return this._matchOne(file, pattern, partial, 0, 0);
};
Minimatch.prototype._matchGlobstar = function(file, pattern, partial, fileIndex, patternIndex) {
var i;
var firstgs = -1;
for (i = patternIndex; i < pattern.length; i++) {
if (pattern[i] === GLOBSTAR) {
firstgs = i;
break;
}
}
var lastgs = -1;
for (i = pattern.length - 1; i >= 0; i--) {
if (pattern[i] === GLOBSTAR) {
lastgs = i;
break;
}
}
var head = pattern.slice(patternIndex, firstgs);
var body = partial ? pattern.slice(firstgs + 1) : pattern.slice(firstgs + 1, lastgs);
var tail = partial ? [] : pattern.slice(lastgs + 1);
if (head.length) {
var fileHead = file.slice(fileIndex, fileIndex + head.length);
if (!this._matchOne(fileHead, head, partial, 0, 0)) {
return false;
}
fileIndex += head.length;
}
var fileTailMatch = 0;
if (tail.length) {
if (tail.length + fileIndex > file.length) return false;
var tailStart = file.length - tail.length;
if (this._matchOne(file, tail, partial, tailStart, 0)) {
fileTailMatch = tail.length;
} else {
if (file[file.length - 1] !== "" || fileIndex + tail.length === file.length) {
return false;
}
tailStart--;
if (!this._matchOne(file, tail, partial, tailStart, 0)) {
return false;
}
fileTailMatch = tail.length + 1;
}
}
if (!body.length) {
var sawSome = !!fileTailMatch;
for (i = fileIndex; i < file.length - fileTailMatch; i++) {
var f = String(file[i]);
sawSome = true;
if (f === "." || f === ".." || !this.options.dot && f.charAt(0) === ".") {
return false;
}
}
return partial || sawSome;
}
var bodySegments = [[[], 0]];
var currentBody = bodySegments[0];
var nonGsParts = 0;
var nonGsPartsSums = [0];
for (var bi = 0; bi < body.length; bi++) {
var b = body[bi];
if (b === GLOBSTAR) {
nonGsPartsSums.push(nonGsParts);
currentBody = [[], 0];
bodySegments.push(currentBody);
} else {
currentBody[0].push(b);
nonGsParts++;
}
}
var idx = bodySegments.length - 1;
var fileLength = file.length - fileTailMatch;
for (var si = 0; si < bodySegments.length; si++) {
bodySegments[si][1] = fileLength - (nonGsPartsSums[idx--] + bodySegments[si][0].length);
}
return !!this._matchGlobStarBodySections(
file,
bodySegments,
fileIndex,
0,
partial,
0,
!!fileTailMatch
);
this.debug("matchOne", file.length, pattern.length);
for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
};
Minimatch.prototype._matchGlobStarBodySections = function(file, bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
var bs = bodySegments[bodyIndex];
if (!bs) {
for (var i = fileIndex; i < file.length; i++) {
sawTail = true;
var f = file[i];
if (f === "." || f === ".." || !this.options.dot && f.charAt(0) === ".") {
return false;
}
}
return sawTail;
}
var body = bs[0];
var after = bs[1];
while (fileIndex <= after) {
var m = this._matchOne(
file.slice(0, fileIndex + body.length),
body,
partial,
fileIndex,
0
);
if (m && globStarDepth < this.maxGlobstarRecursion) {
var sub = this._matchGlobStarBodySections(
file,
bodySegments,
fileIndex + body.length,
bodyIndex + 1,
partial,
globStarDepth + 1,
sawTail
);
if (sub !== false) {
return sub;
}
}
var f = file[fileIndex];
if (f === "." || f === ".." || !this.options.dot && f.charAt(0) === ".") {
return false;
}
fileIndex++;
}
return partial || null;
};
Minimatch.prototype._matchOne = function(file, pattern, partial, fileIndex, patternIndex) {
var fi, pi, fl, pl;
for (fi = fileIndex, pi = patternIndex, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
this.debug("matchOne loop");
var p = pattern[pi];
var f = file[fi];
this.debug(pattern, p, f);
if (p === false) return false;
if (p === GLOBSTAR) {
this.debug("GLOBSTAR", [pattern, p, f]);
var fr = fi;
var pr = pi + 1;
if (pr === pl) {
this.debug("** at the end");
for (; fi < fl; fi++) {
if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".") return false;
}
return true;
}
while (fr < fl) {
var swallowee = file[fr];
this.debug("\nglobstar while", file, fr, pattern, pr, swallowee);
if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
this.debug("globstar found match!", fr, fl, swallowee);
return true;
} else {
if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
this.debug("dot detected!", file, fr, pattern, pr);
break;
}
this.debug("globstar swallow a segment, and continue");
fr++;
}
}
if (partial) {
this.debug("\n>>> no match, partial?", file, fr, pattern, pr);
if (fr === fl) return true;
}
return false;
}
if (p === false || p === GLOBSTAR) return false;
var hit;
if (typeof p === "string") {
hit = f === p;