Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

micromatch

Package Overview
Dependencies
Maintainers
3
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

micromatch - npm Package Compare versions

Comparing version 2.1.2 to 2.1.3

73

lib/expand.js

@@ -37,7 +37,2 @@ /*!

function replace(re, str) {
glob.repl(re, esc(str));
pattern = glob.pattern;
}
// return early if glob pattern matches special patterns

@@ -52,3 +47,3 @@ if (specialCase(pattern) && opts.safemode) {

glob.repl('/.', '/\\.');
glob._replace('/.', '/\\.');

@@ -92,7 +87,7 @@ // parse the glob pattern into tokens

glob.repl('[]', '\\[\\]');
glob.repl('(?', '__QMARK_GROUP__');
glob._replace('[]', '\\[\\]');
glob._replace('(?', '__QMARK_GROUP__');
// windows drives
replace(/^(\w):([\\\/]+?)/gi, lookahead + '$1:$2');
glob._replace(/^(\w):([\\\/]+?)/gi, lookahead + '$1:$2', true);

@@ -109,4 +104,4 @@ // negate slashes in exclusion ranges

if (/^\*\.\w*$/.test(glob.pattern)) {
glob.repl('*', star(opts.dot) + '\\');
glob.repl('__QMARK_GROUP__', '(?');
glob._replace('*', star(opts.dot) + '\\');
glob._replace('__QMARK_GROUP__', '(?');
return glob;

@@ -116,3 +111,3 @@ }

// '/*/*/*' => '(?:/*){3}'
glob.repl(/(\/\*)+/g, function (match) {
glob._replace(/(\/\*)+/g, function (match) {
var len = match.length / 2;

@@ -135,4 +130,3 @@ if (len === 1) { return match; }

if (tok.is.globstar) {
glob.repl(/\*{2,}/g, '**');
glob.pattern = collapse(glob.pattern, '**/');
glob._replace(/\*{2,}/g, '**');
glob.pattern = collapse(glob.pattern, '/**');

@@ -142,22 +136,19 @@ glob.pattern = optionalGlobstar(glob.pattern);

// reduce extraneous globstars
glob.repl(/(^|[^\\])\*{2,}([^\\]|$)/g, '$1**$2');
glob._replace(/(^|[^\\])\*{2,}([^\\]|$)/g, '$1**$2');
// 'foo/**'
replace(/(\w+)\*\*(?!\/)/g, '(?=.)$1[^/]*?');
replace('**/', '.*\\/');
replace('**', globstar(opts));
replace('/*', '\\/?' + nodot + '[^\\/]*?');
// 'foo/*'
glob._replace(/(\w+)\*(?!\/)/g, '(?=.)$1[^/]*?', true);
glob._replace('**', globstar(opts), true);
}
// ends with /*
replace(/\/\*$/, '\\/' + stardot(opts));
glob._replace(/\/\*$/, '\\/' + stardot(opts), true);
// ends with *, no slashes
replace(/(?!\/)\*$/, boxQ);
glob._replace(/(?!\/)\*$/, boxQ, true);
// has '*'
replace('*', stardot(opts));
glob._replace('*', stardot(opts), true);
glob._replace('?.', '?\\.', true);
glob._replace('?:', '?:', true);
replace('?.', '?\\.');
replace('?:', '?:');
glob.repl(/\?+/g, function (match) {
glob._replace(/\?+/g, function (match) {
var len = match.length;

@@ -171,18 +162,18 @@ if (len === 1) {

// escape '.abc' => '\\.abc'
glob.repl(/\.([*\w]+)/g, '\\.$1');
glob._replace(/\.([*\w]+)/g, '\\.$1');
// fix '[^\\\\/]'
glob.repl(/\[\^[\\\/]+\]/g, box);
glob._replace(/\[\^[\\\/]+\]/g, box);
// '///' => '\/'
glob.repl(/\/+/g, '\\/');
glob._replace(/\/+/g, '\\/');
// '\\\\\\' => '\\'
glob.repl(/\\{2,}/g, '\\');
glob._replace(/\\{2,}/g, '\\');
}
glob.repl('__QMARK_GROUP__', '(?');
glob._replace('__QMARK_GROUP__', '(?');
glob.unescape(glob.pattern);
glob.repl('__UNESC_STAR__', '*');
glob.repl('%~', '?');
glob.repl('%%', '*');
glob.repl('?.', '?\\.');
glob.repl('[^\\/]', '[^/]');
glob._replace('__UNESC_STAR__', '*');
glob._replace('%~', '?');
glob._replace('%%', '*');
glob._replace('?.', '?\\.');
glob._replace('[^\\/]', '[^/]');
return glob;

@@ -220,7 +211,7 @@ }

} else {
glob.repl(/(?!\()\?/g, '[^/]');
glob._replace(/(?!\()\?/g, '[^/]');
if (tok.path.basename.charAt(0) !== '.') {
opts.dot = true;
}
glob.repl('*', star(opts.dot));
glob._replace('*', star(opts.dot));
}

@@ -233,5 +224,5 @@ }

glob.repl('__QMARK_GROUP__', '(?');
glob._replace('__QMARK_GROUP__', '(?');
glob.unescape(glob.pattern);
glob.repl('__UNESC_STAR__', '*');
glob._replace('__UNESC_STAR__', '*');
return glob;

@@ -238,0 +229,0 @@ }

@@ -138,24 +138,24 @@ 'use strict';

/**
* Replace `a` with `b`. Also tracks the change
* before and after each replacement. This is
* disabled by default, but can be enabled by
* setting `options.track` to true.
* Replace `a` with `b`. Also tracks the change before and
* after each replacement. This is disabled by default, but
* can be enabled by setting `options.track` to true.
*
* Also, when the pattern is a string, `.split()` is used,
* because it's much faster than replace.
*
* @param {RegExp|String} `a`
* @param {String} `b`
* @param {Boolean} `escape` When `true`, escapes `*` and `?` in the replacement.
* @return {String}
*/
Glob.prototype.repl = function(a, b, c) {
this.track('before ' + c || '');
Glob.prototype._replace = function(a, b, escape) {
this.track('before (find): "' + a + '" (replace with): "' + b + '"');
if (escape) b = esc(b);
if (a && b && typeof a === 'string') {
this.pattern = this.pattern.split(a).join(b);
} else if (a instanceof RegExp) {
try {
this.pattern = this.pattern.replace(a, b);
} catch(err) {}
this.pattern = this.pattern.replace(a, b);
}
this.track('after ' + c || '');
this.track('after');
};

@@ -202,1 +202,11 @@

};
/**
* Escape utils
*/
function esc(str) {
str = str.split('?').join('%~');
str = str.split('*').join('%%');
return str;
}
{
"name": "micromatch",
"description": "Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. Just use `micromatch.isMatch()` instead of `minimatch()`, or use `micromatch()` instead of `multimatch()`.",
"version": "2.1.2",
"version": "2.1.3",
"homepage": "https://github.com/jonschlinkert/micromatch",

@@ -6,0 +6,0 @@ "author": {

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