Socket
Socket
Sign inDemoInstall

is-glob

Package Overview
Dependencies
1
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.1.0 to 4.0.0

33

index.js
/*!
* is-glob <https://github.com/jonschlinkert/is-glob>
*
* Copyright (c) 2014-2016, Jon Schlinkert.
* Licensed under the MIT License.
* Copyright (c) 2014-2017, Jon Schlinkert.
* Released under the MIT License.
*/
var isExtglob = require('is-extglob');
var chars = { '{': '}', '(': ')', '[': ']'};
module.exports = function isGlob(str) {
module.exports = function isGlob(str, options) {
if (typeof str !== 'string' || str === '') {

@@ -15,12 +16,32 @@ return false;

if (isExtglob(str)) return true;
if (isExtglob(str)) {
return true;
}
var regex = /(\\).|([*?]|\[.*\]|\{.*\}|\(.*\|.*\)|^!)/;
var regex = /\\(.)|(^!|\*|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\))/;
var match;
// optionally relax regex
if (options && options.strict === false) {
regex = /\\(.)|(^!|[*?{}()[\]]|\(\?)/;
}
while ((match = regex.exec(str))) {
if (match[2]) return true;
str = str.slice(match.index + match[0].length);
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;
};

9

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": "3.1.0",
"version": "4.0.0",
"homepage": "https://github.com/jonschlinkert/is-glob",
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
"contributors": [
"Daniel Perez <daniel@claudetech.com> (http://tuvistavie.com)",
"Jon Schlinkert <jon.schlinkert@sellside.com> (http://twitter.com/jonschlinkert)"
"Brian Woodward (https://twitter.com/doowb)",
"Daniel Perez (https://tuvistavie.com)",
"Jon Schlinkert (http://twitter.com/jonschlinkert)"
],

@@ -27,3 +28,3 @@ "repository": "jonschlinkert/is-glob",

"dependencies": {
"is-extglob": "^2.1.0"
"is-extglob": "^2.1.1"
},

@@ -30,0 +31,0 @@ "devDependencies": {

@@ -1,2 +0,2 @@

# is-glob [![NPM version](https://img.shields.io/npm/v/is-glob.svg?style=flat)](https://www.npmjs.com/package/is-glob) [![NPM downloads](https://img.shields.io/npm/dm/is-glob.svg?style=flat)](https://npmjs.org/package/is-glob) [![Build Status](https://img.shields.io/travis/jonschlinkert/is-glob.svg?style=flat)](https://travis-ci.org/jonschlinkert/is-glob)
# is-glob [![NPM version](https://img.shields.io/npm/v/is-glob.svg?style=flat)](https://www.npmjs.com/package/is-glob) [![NPM monthly downloads](https://img.shields.io/npm/dm/is-glob.svg?style=flat)](https://npmjs.org/package/is-glob) [![NPM total downloads](https://img.shields.io/npm/dt/is-glob.svg?style=flat)](https://npmjs.org/package/is-glob) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/is-glob.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/is-glob) [![Windows Build Status](https://img.shields.io/appveyor/ci/jonschlinkert/is-glob.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/jonschlinkert/is-glob)

@@ -21,2 +21,4 @@ > 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.

### Default behavior
**True**

@@ -34,3 +36,2 @@

isGlob('abc/{a,b}.js');
isGlob('abc/?.js');
//=> true

@@ -67,3 +68,2 @@ ```

isGlob('abc/\\{a,b}.js');
isGlob('abc/\\?.js');
//=> false

@@ -80,2 +80,3 @@ ```

isGlob('abc/+.js');
isGlob('abc/?.js');
isGlob();

@@ -94,2 +95,48 @@ isGlob(null);

### Option strict
When `options.strict === false` the behavior is less strict in determining if a pattern is a glob. Meaning that
some patterns that would return `false` may return `true`. This is done so that matching libraries like [micromatch](https://github.com/micromatch/micromatch) have a chance at determining if the pattern is a glob or not.
**True**
Patterns that have glob characters or regex patterns will return `true`:
```js
isGlob('!foo.js', {strict: false});
isGlob('*.js', {strict: false});
isGlob('**/abc.js', {strict: false});
isGlob('abc/*.js', {strict: false});
isGlob('abc/(aaa|bbb).js', {strict: false});
isGlob('abc/[a-z].js', {strict: false});
isGlob('abc/{a,b}.js', {strict: false});
//=> true
```
Extglobs
```js
isGlob('abc/@(a).js', {strict: false});
isGlob('abc/!(a).js', {strict: false});
isGlob('abc/+(a).js', {strict: false});
isGlob('abc/*(a).js', {strict: false});
isGlob('abc/?(a).js', {strict: false});
//=> true
```
**False**
Escaped globs or extglobs return `false`:
```js
isGlob('\\!foo.js', {strict: false});
isGlob('\\*.js', {strict: false});
isGlob('\\*\\*/abc.js', {strict: false});
isGlob('abc/\\*.js', {strict: false});
isGlob('abc/\\(aaa|bbb).js', {strict: false});
isGlob('abc/\\[a-z].js', {strict: false});
isGlob('abc/\\{a,b}.js', {strict: false});
//=> false
```
## About

@@ -100,3 +147,3 @@

* [assemble](https://www.npmjs.com/package/assemble): Get the rocks out of your socks! Assemble makes you fast at creating web projects… [more](https://github.com/assemble/assemble) | [homepage](https://github.com/assemble/assemble "Get the rocks out of your socks! Assemble makes you fast at creating web projects. Assemble is used by thousands of projects for rapid prototyping, creating themes, scaffolds, boilerplates, e-books, UI components, API documentation, blogs, building websit")
* [base](https://www.npmjs.com/package/base): base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… [more](https://github.com/node-base/base) | [homepage](https://github.com/node-base/base "base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting with a handful of common methods, like `set`, `get`, `del` and `use`.")
* [base](https://www.npmjs.com/package/base): Framework for rapidly creating high quality node.js applications, using plugins like building blocks | [homepage](https://github.com/node-base/base "Framework for rapidly creating high quality node.js applications, using plugins like building blocks")
* [update](https://www.npmjs.com/package/update): Be scalable! Update is a new, open source developer framework and CLI for automating updates… [more](https://github.com/update/update) | [homepage](https://github.com/update/update "Be scalable! Update is a new, open source developer framework and CLI for automating updates of any kind in code projects.")

@@ -111,15 +158,16 @@ * [verb](https://www.npmjs.com/package/verb): Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used… [more](https://github.com/verbose/verb) | [homepage](https://github.com/verbose/verb "Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used on hundreds of projects of all sizes to generate everything from API docs to readmes.")

| **Commits** | **Contributor**<br/> |
| --- | --- |
| 40 | [jonschlinkert](https://github.com/jonschlinkert) |
| 1 | [tuvistavie](https://github.com/tuvistavie) |
| **Commits** | **Contributor** |
| --- | --- |
| 47 | [jonschlinkert](https://github.com/jonschlinkert) |
| 1 | [doowb](https://github.com/doowb) |
| 1 | [tuvistavie](https://github.com/tuvistavie) |
### Building docs
_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
To generate the readme and API documentation with [verb](https://github.com/verbose/verb):
To generate the readme, run the following command:
```sh
$ npm install -g verb verb-generate-readme && verb
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```

@@ -129,6 +177,6 @@

Install dev dependencies:
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
```sh
$ npm install -d && npm test
$ npm install && npm test
```

@@ -141,11 +189,11 @@

* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
### License
Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT license](https://github.com/jonschlinkert/is-glob/blob/master/LICENSE).
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).
***
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.1.31, on October 12, 2016._
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on August 07, 2017._

Sorry, the diff of this file is not supported yet

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