Socket
Socket
Sign inDemoInstall

minimatch

Package Overview
Dependencies
3
Maintainers
1
Versions
107
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.5 to 3.0.6

103

minimatch.js
module.exports = minimatch
minimatch.Minimatch = Minimatch
const path = (() => { try { return require('path') } catch (e) {}})() || {
var path = (function () { try { return require('path') } catch (e) {}}()) || {
sep: '/'

@@ -9,6 +9,6 @@ }

const GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
const expand = require('brace-expansion')
var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
var expand = require('brace-expansion')
const plTypes = {
var plTypes = {
'!': { open: '(?:(?!(?:', close: '))[^/]*?)'},

@@ -23,6 +23,6 @@ '?': { open: '(?:', close: ')?' },

// don't need to escape / when using new RegExp()
const qmark = '[^/]'
var qmark = '[^/]'
// * => any number of characters
const star = qmark + '*?'
var star = qmark + '*?'

@@ -32,10 +32,10 @@ // ** when dots are allowed. Anything goes, except .. and .

// followed by anything, any number of times.
const twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?'
var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?'
// not a ^ or / followed by a dot,
// followed by anything, any number of times.
const twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?'
var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?'
// characters that need to be escaped in RegExp.
const reSpecials = charSet('().*{}+?[]^$\\!')
var reSpecials = charSet('().*{}+?[]^$\\!')

@@ -51,3 +51,3 @@ // "abc" -> { a:true, b:true, c:true }

// normalizes slashes.
const slashSplit = /\/+/
var slashSplit = /\/+/

@@ -63,5 +63,4 @@ minimatch.filter = filter

function ext (a, b) {
a = a || {}
b = b || {}
const t = {}
var t = {}
Object.keys(a).forEach(function (k) {

@@ -81,5 +80,5 @@ t[k] = a[k]

const orig = minimatch
var orig = minimatch
const m = function minimatch (p, pattern, options) {
var m = function minimatch (p, pattern, options) {
return orig(p, pattern, ext(def, options))

@@ -91,3 +90,3 @@ }

}
m.Minimatch.defaults = options => {
m.Minimatch.defaults = function defaults (options) {
return orig.defaults(ext(def, options)).Minimatch

@@ -133,5 +132,2 @@ }

// "" only matches ""
if (pattern.trim() === '') return p === ''
return new Minimatch(pattern, options).match(p)

@@ -148,3 +144,2 @@ }

if (!options) options = {}
pattern = pattern.trim()

@@ -163,2 +158,3 @@ // windows support: need to use /, not \

this.empty = false
this.partial = !!options.partial

@@ -173,5 +169,2 @@ // make the set of regexps etc.

function make () {
// don't do it more than once.
if (this._made) return
var pattern = this.pattern

@@ -196,3 +189,3 @@ var options = this.options

if (options.debug) this.debug = console.error
if (options.debug) this.debug = function debug() { console.error.apply(console, arguments) }

@@ -279,2 +272,4 @@ this.debug(this.pattern, set)

// Thanks to Yeting Li <https://github.com/yetingli> for
// improving this regexp to avoid a ReDOS vulnerability.
if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {

@@ -288,4 +283,4 @@ // shortcut. no need to expand.

const MAX_PATTERN_LENGTH = 1024 * 64
const assertValidPattern = pattern => {
var MAX_PATTERN_LENGTH = 1024 * 64
var assertValidPattern = function (pattern) {
if (typeof pattern !== 'string') {

@@ -312,3 +307,3 @@ throw new TypeError('invalid pattern')

Minimatch.prototype.parse = parse
const SUBPARSE = {}
var SUBPARSE = {}
function parse (pattern, isSub) {

@@ -320,3 +315,8 @@ assertValidPattern(pattern)

// shortcuts
if (!options.noglobstar && pattern === '**') return GLOBSTAR
if (pattern === '**') {
if (!options.noglobstar)
return GLOBSTAR
else
pattern = '*'
}
if (pattern === '') return ''

@@ -377,3 +377,4 @@

switch (c) {
case '/': /* istanbul ignore next */ {
/* istanbul ignore next */
case '/': {
// completely not allowed, even escaped.

@@ -501,21 +502,19 @@ // Should already be path-split by now.

// "[z-a]" is valid, equivalent to "\[z-a\]"
if (inClass) {
// split where the last [ was, make sure we don't have
// an invalid re. if so, re-walk the contents of the
// would-be class to re-translate any characters that
// were passed through as-is
// TODO: It would probably be faster to determine this
// without a try/catch and a new RegExp, but it's tricky
// to do safely. For now, this is safe and works.
var cs = pattern.substring(classStart + 1, i)
try {
RegExp('[' + cs + ']')
} catch (er) {
// not a valid class!
var sp = this.parse(cs, SUBPARSE)
re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'
hasMagic = hasMagic || sp[1]
inClass = false
continue
}
// split where the last [ was, make sure we don't have
// an invalid re. if so, re-walk the contents of the
// would-be class to re-translate any characters that
// were passed through as-is
// TODO: It would probably be faster to determine this
// without a try/catch and a new RegExp, but it's tricky
// to do safely. For now, this is safe and works.
var cs = pattern.substring(classStart + 1, i)
try {
RegExp('[' + cs + ']')
} catch (er) {
// not a valid class!
var sp = this.parse(cs, SUBPARSE)
re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'
hasMagic = hasMagic || sp[1]
inClass = false
continue
}

@@ -604,5 +603,3 @@

switch (re.charAt(0)) {
case '.':
case '[':
case '(': addPatternStart = true
case '[': case '.': case '(': addPatternStart = true
}

@@ -735,3 +732,3 @@

options = options || {}
const mm = new Minimatch(pattern, options)
var mm = new Minimatch(pattern, options)
list = list.filter(function (f) {

@@ -746,4 +743,4 @@ return mm.match(f)

Minimatch.prototype.match = match
function match (f, partial) {
Minimatch.prototype.match = function match (f, partial) {
if (typeof partial === 'undefined') partial = this.partial
this.debug('match', f, this.pattern)

@@ -750,0 +747,0 @@ // short-circuit in the case of busted things.

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

"description": "a glob matcher in javascript",
"version": "3.0.5",
"version": "3.0.6",
"repository": {

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

@@ -174,3 +174,18 @@ # minimatch

### partial
Compare a partial path to a pattern. As long as the parts of the path that
are present are not contradicted by the pattern, it will be treated as a
match. This is useful in applications where you're walking through a
folder structure, and don't yet have the full path, but want to ensure that
you do not walk down paths that can never be a match.
For example,
```js
minimatch('/a/b', '/a/*/c/d', { partial: true }) // true, might be /a/b/c/d
minimatch('/a/b', '/**/d', { partial: true }) // true, might be /a/b/.../d
minimatch('/x/y/z', '/a/**/z', { partial: true }) // false, because x !== a
```
## Comparisons to other fnmatch/glob implementations

@@ -177,0 +192,0 @@

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc