Socket
Socket
Sign inDemoInstall

minimatch

Package Overview
Dependencies
Maintainers
1
Versions
110
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

minimatch - npm Package Compare versions

Comparing version 9.0.1 to 9.0.2

7

dist/cjs/ast.d.ts

@@ -17,9 +17,4 @@ import { MinimatchOptions, MMRegExp } from './index.js';

toMMPattern(): MMRegExp | string;
toRegExpSource(): [
re: string,
body: string,
hasMagic: boolean,
uflag: boolean
];
toRegExpSource(allowDot?: boolean): [re: string, body: string, hasMagic: boolean, uflag: boolean];
}
//# sourceMappingURL=ast.d.ts.map

71

dist/cjs/ast.js

@@ -13,3 +13,3 @@ "use strict";

// Exts don't need the ^ or / bit, because the root binds that already.
const startNoTraversal = '(?!\\.\\.?(?:$|/))';
const startNoTraversal = '(?!(?:^|/)\\.\\.?(?:$|/))';
const startNoDot = '(?!\\.)';

@@ -411,3 +411,4 @@ // characters that indicate a start of pattern needs the "no dots" bit,

// or start or whatever) and prepend ^ or / at the Regexp construction.
toRegExpSource() {
toRegExpSource(allowDot) {
const dot = allowDot ?? !!this.#options.dot;
if (this.#root === this)

@@ -421,3 +422,3 @@ this.#fillNegs();

? AST.#parseGlob(p, this.#hasMagic, noEmpty)
: p.toRegExpSource();
: p.toRegExpSource(allowDot);
this.#hasMagic = this.#hasMagic || hasMagic;

@@ -442,3 +443,3 @@ this.#uflag = this.#uflag || uflag;

// dots are allowed, and the pattern starts with [ or .
(this.#options.dot && aps.has(src.charAt(0))) ||
(dot && aps.has(src.charAt(0))) ||
// the pattern starts with \., and then [ or .

@@ -450,3 +451,3 @@ (src.startsWith('\\.') && aps.has(src.charAt(2))) ||

// sub-pattern will be preventing it anyway.
const needNoDot = !this.#options.dot && aps.has(src.charAt(0));
const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
start = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : '';

@@ -471,19 +472,9 @@ }

}
// We need to calculate the body *twice* if it's a repeat pattern
// at the start, once in nodot mode, then again in dot mode, so a
// pattern like *(?) can match 'x.y'
const repeated = this.type === '*' || this.type === '+';
// some kind of extglob
const start = this.type === '!' ? '(?:(?!(?:' : '(?:';
const body = this.#parts
.map(p => {
// extglob ASTs should only contain parent ASTs
/* c8 ignore start */
if (typeof p === 'string') {
throw new Error('string type in extglob ast??');
}
/* c8 ignore stop */
// can ignore hasMagic, because extglobs are already always magic
const [re, _, _hasMagic, uflag] = p.toRegExpSource();
this.#uflag = this.#uflag || uflag;
return re;
})
.filter(p => !(this.isStart() && this.isEnd()) || !!p)
.join('|');
let body = this.#partsToRegExp(dot);
if (this.isStart() && this.isEnd() && !body && this.type !== '!') {

@@ -498,7 +489,16 @@ // invalid extglob, has to at least be *something* present, if it's

}
// XXX abstract out this map method
let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot
? ''
: this.#partsToRegExp(true);
if (bodyDotAllowed === body) {
bodyDotAllowed = '';
}
if (bodyDotAllowed) {
body = `(?:${body})(?:${bodyDotAllowed})*?`;
}
// an empty !() is exactly equivalent to a starNoEmpty
let final = '';
if (this.type === '!' && this.#emptyExt) {
final =
(this.isStart() && !this.#options.dot ? startNoDot : '') + starNoEmpty;
final = (this.isStart() && !dot ? startNoDot : '') + starNoEmpty;
}

@@ -509,3 +509,3 @@ else {

'))' +
(this.isStart() && !this.#options.dot ? startNoDot : '') +
(this.isStart() && !dot && !allowDot ? startNoDot : '') +
star +

@@ -515,3 +515,9 @@ ')'

? ')'
: `)${this.type}`;
: this.type === '?'
? ')?'
: this.type === '+' && bodyDotAllowed
? ')'
: this.type === '*' && bodyDotAllowed
? `)?`
: `)${this.type}`;
final = start + body + close;

@@ -526,2 +532,19 @@ }

}
#partsToRegExp(dot) {
return this.#parts
.map(p => {
// extglob ASTs should only contain parent ASTs
/* c8 ignore start */
if (typeof p === 'string') {
throw new Error('string type in extglob ast??');
}
/* c8 ignore stop */
// can ignore hasMagic, because extglobs are already always magic
const [re, _, _hasMagic, uflag] = p.toRegExpSource(dot);
this.#uflag = this.#uflag || uflag;
return re;
})
.filter(p => !(this.isStart() && this.isEnd()) || !!p)
.join('|');
}
static #parseGlob(glob, hasMagic, noEmpty = false) {

@@ -528,0 +551,0 @@ let escaping = false;

@@ -17,9 +17,4 @@ import { MinimatchOptions, MMRegExp } from './index.js';

toMMPattern(): MMRegExp | string;
toRegExpSource(): [
re: string,
body: string,
hasMagic: boolean,
uflag: boolean
];
toRegExpSource(allowDot?: boolean): [re: string, body: string, hasMagic: boolean, uflag: boolean];
}
//# sourceMappingURL=ast.d.ts.map

@@ -10,3 +10,3 @@ // parse a single path portion

// Exts don't need the ^ or / bit, because the root binds that already.
const startNoTraversal = '(?!\\.\\.?(?:$|/))';
const startNoTraversal = '(?!(?:^|/)\\.\\.?(?:$|/))';
const startNoDot = '(?!\\.)';

@@ -408,3 +408,4 @@ // characters that indicate a start of pattern needs the "no dots" bit,

// or start or whatever) and prepend ^ or / at the Regexp construction.
toRegExpSource() {
toRegExpSource(allowDot) {
const dot = allowDot ?? !!this.#options.dot;
if (this.#root === this)

@@ -418,3 +419,3 @@ this.#fillNegs();

? AST.#parseGlob(p, this.#hasMagic, noEmpty)
: p.toRegExpSource();
: p.toRegExpSource(allowDot);
this.#hasMagic = this.#hasMagic || hasMagic;

@@ -439,3 +440,3 @@ this.#uflag = this.#uflag || uflag;

// dots are allowed, and the pattern starts with [ or .
(this.#options.dot && aps.has(src.charAt(0))) ||
(dot && aps.has(src.charAt(0))) ||
// the pattern starts with \., and then [ or .

@@ -447,3 +448,3 @@ (src.startsWith('\\.') && aps.has(src.charAt(2))) ||

// sub-pattern will be preventing it anyway.
const needNoDot = !this.#options.dot && aps.has(src.charAt(0));
const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
start = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : '';

@@ -468,19 +469,9 @@ }

}
// We need to calculate the body *twice* if it's a repeat pattern
// at the start, once in nodot mode, then again in dot mode, so a
// pattern like *(?) can match 'x.y'
const repeated = this.type === '*' || this.type === '+';
// some kind of extglob
const start = this.type === '!' ? '(?:(?!(?:' : '(?:';
const body = this.#parts
.map(p => {
// extglob ASTs should only contain parent ASTs
/* c8 ignore start */
if (typeof p === 'string') {
throw new Error('string type in extglob ast??');
}
/* c8 ignore stop */
// can ignore hasMagic, because extglobs are already always magic
const [re, _, _hasMagic, uflag] = p.toRegExpSource();
this.#uflag = this.#uflag || uflag;
return re;
})
.filter(p => !(this.isStart() && this.isEnd()) || !!p)
.join('|');
let body = this.#partsToRegExp(dot);
if (this.isStart() && this.isEnd() && !body && this.type !== '!') {

@@ -495,7 +486,16 @@ // invalid extglob, has to at least be *something* present, if it's

}
// XXX abstract out this map method
let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot
? ''
: this.#partsToRegExp(true);
if (bodyDotAllowed === body) {
bodyDotAllowed = '';
}
if (bodyDotAllowed) {
body = `(?:${body})(?:${bodyDotAllowed})*?`;
}
// an empty !() is exactly equivalent to a starNoEmpty
let final = '';
if (this.type === '!' && this.#emptyExt) {
final =
(this.isStart() && !this.#options.dot ? startNoDot : '') + starNoEmpty;
final = (this.isStart() && !dot ? startNoDot : '') + starNoEmpty;
}

@@ -506,3 +506,3 @@ else {

'))' +
(this.isStart() && !this.#options.dot ? startNoDot : '') +
(this.isStart() && !dot && !allowDot ? startNoDot : '') +
star +

@@ -512,3 +512,9 @@ ')'

? ')'
: `)${this.type}`;
: this.type === '?'
? ')?'
: this.type === '+' && bodyDotAllowed
? ')'
: this.type === '*' && bodyDotAllowed
? `)?`
: `)${this.type}`;
final = start + body + close;

@@ -523,2 +529,19 @@ }

}
#partsToRegExp(dot) {
return this.#parts
.map(p => {
// extglob ASTs should only contain parent ASTs
/* c8 ignore start */
if (typeof p === 'string') {
throw new Error('string type in extglob ast??');
}
/* c8 ignore stop */
// can ignore hasMagic, because extglobs are already always magic
const [re, _, _hasMagic, uflag] = p.toRegExpSource(dot);
this.#uflag = this.#uflag || uflag;
return re;
})
.filter(p => !(this.isStart() && this.isEnd()) || !!p)
.join('|');
}
static #parseGlob(glob, hasMagic, noEmpty = false) {

@@ -525,0 +548,0 @@ let escaping = false;

@@ -5,3 +5,3 @@ {

"description": "a glob matcher in javascript",
"version": "9.0.1",
"version": "9.0.2",
"repository": {

@@ -8,0 +8,0 @@ "type": "git",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc