Socket
Socket
Sign inDemoInstall

is-glob

Package Overview
Dependencies
1
Maintainers
3
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.1 to 4.0.2

140

index.js

@@ -10,5 +10,113 @@ /*!

var chars = { '{': '}', '(': ')', '[': ']'};
var strictRegex = /\\(.)|(^!|\*|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\))/;
var relaxedRegex = /\\(.)|(^!|[*?{}()[\]]|\(\?)/;
var strictCheck = function (str) {
if (str[0] === '!') {
return true;
}
var index = 0;
while (index < str.length) {
if (str[index] === '*') {
return true;
}
if (str[index + 1] === '?' && /[\].+)]/.test(str[index])) {
return true;
}
if (str[index] === '[' && str[index + 1] !== ']') {
var closeIndex = str.indexOf(']', index);
if (closeIndex > index) {
var slashIndex = str.indexOf('\\', index);
if (slashIndex === -1 || slashIndex > closeIndex) {
return true;
}
}
}
if (str[index] === '{' && str[index + 1] !== '}') {
closeIndex = str.indexOf('}', index);
if (closeIndex > index) {
slashIndex = str.indexOf('\\', index);
if (slashIndex === -1 || slashIndex > closeIndex) {
return true;
}
}
}
if (str[index] === '(' && str[index + 1] === '?' && /[:!=]/.test(str[index + 2]) && str[index + 3] !== ')') {
closeIndex = str.indexOf(')', index);
if (closeIndex > index) {
slashIndex = str.indexOf('\\', index);
if (slashIndex === -1 || slashIndex > closeIndex) {
return true;
}
}
}
if (str[index] === '(' && str[index + 1] !== '|') {
var pipeIndex = str.indexOf('|', index);
if (pipeIndex > index && str[pipeIndex + 1] !== ')') {
closeIndex = str.indexOf(')', pipeIndex);
if (closeIndex > pipeIndex) {
slashIndex = str.indexOf('\\', pipeIndex);
if (slashIndex === -1 || slashIndex > closeIndex) {
return true;
}
}
}
}
if (str[index] === '\\') {
var open = str[index+1];
index += 2;
var close = chars[open];
if (close) {
var n = str.indexOf(close, index);
if (n !== -1) {
index = n + 1;
}
}
if (str[index] === '!') {
return true;
}
} else {
index++;
}
}
return false;
}
var relaxedCheck = function (str) {
if (str[0] === '!') {
return true;
}
var index = 0;
while (index < str.length) {
if (/[*?{}()[\]]/.test(str[index])) {
return true;
}
if (str[index] === '\\') {
var open = str[index+1];
index += 2;
var close = chars[open];
if (close) {
var n = str.indexOf(close, index);
if (n !== -1) {
index = n + 1;
}
}
if (str[index] === '!') {
return true;
}
} else {
index++;
}
}
return false;
}
module.exports = function isGlob(str, options) {

@@ -23,28 +131,10 @@ if (typeof str !== 'string' || str === '') {

var regex = strictRegex;
var match;
var check = strictCheck;
// optionally relax regex
// optionally relax check
if (options && options.strict === false) {
regex = relaxedRegex;
check = relaxedCheck;
}
while ((match = regex.exec(str))) {
if (match[2]) return true;
var idx = match.index + match[0].length;
// if an open bracket/brace/paren is escaped,
// set the index to the next closing character
var open = match[1];
var close = open ? chars[open] : null;
if (open && close) {
var n = str.indexOf(close, idx);
if (n !== -1) {
idx = n + 1;
}
}
str = str.slice(idx);
}
return false;
};
return check(str);
}

2

package.json
{
"name": "is-glob",
"description": "Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a better user experience.",
"version": "4.0.1",
"version": "4.0.2",
"homepage": "https://github.com/micromatch/is-glob",

@@ -6,0 +6,0 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

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