Socket
Socket
Sign inDemoInstall

nanomatch

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nanomatch - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

65

lib/parsers.js

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

var cached;
var NOT_REGEX = '[!*+?$^.\\\\/\\[]+';
var NOT_REGEX = '[!*+?$^"\'.\\\\/\\[]+';
var not = createTextRegex(NOT_REGEX);

@@ -45,18 +45,14 @@

/**
* Quoted strings
* Escape: "\\."
*/
.capture('quoted', function() {
if (this.parsed) return;
.capture('escape', function() {
if (this.isInside('bracket')) return;
var pos = this.position();
var m = this.match(/^(["'])(?=.*\1)/);
var m = this.match(/^(?:\\(.)|([$^]))/);
if (!m) return;
var quote = m[1];
var tok = advanceTo(this.input, quote);
this.consume(tok.len);
return pos({
type: 'quoted',
val: tok.val
type: 'escape',
val: m[2] || m[1]
});

@@ -66,14 +62,24 @@ })

/**
* Escape: "\\."
* Quoted strings
*/
.capture('escape', function() {
if (this.isInside('bracket')) return;
.capture('quoted', function() {
var pos = this.position();
var m = this.match(/^(?:\\(.)|([$^]))/);
var m = this.match(/^["']/);
if (!m) return;
var quote = m[0];
if (this.input.indexOf(quote) === -1) {
return pos({
type: 'escape',
val: quote
});
}
var tok = advanceTo(this.input, quote);
this.consume(tok.len);
return pos({
type: 'escape',
val: m[2] || m[1]
type: 'quoted',
val: tok.esc
});

@@ -98,7 +104,2 @@ })

var node = pos({
type: 'not',
val: val
});
// if nothing has been parsed, we know `!` is at the start,

@@ -109,5 +110,8 @@ // so we need to wrap the result in a negation regex

this.append = ')$).*';
node.val = '';
val = '';
}
return node;
return pos({
type: 'not',
val: val
});
})

@@ -209,3 +213,3 @@

var pos = this.position();
var m = this.match(/^\\(?![*+?(){}\[\]])/);
var m = this.match(/^\\(?![*+?(){}\[\]'"])/);
if (!m) return;

@@ -317,8 +321,11 @@

var ch = input.charAt(0);
var tok = { len: 1 };
var val = '';
var tok = { len: 1, val: '', esc: '' };
var idx = 0;
function advance() {
if (ch !== '\\') val += '\\' + ch;
if (ch !== '\\') {
tok.esc += '\\' + ch;
tok.val += ch;
}
ch = input.charAt(++idx);

@@ -336,4 +343,2 @@ tok.len++;

}
tok.val = val;
return tok;

@@ -340,0 +345,0 @@ }

{
"name": "nanomatch",
"description": "Fast, minimal glob matcher for node.js. Similar to micromatch, minimatch and multimatch, but complete Bash 4.3 wildcard support only (no support for exglobs, posix brackets or braces)",
"version": "1.1.0",
"version": "1.1.1",
"homepage": "https://github.com/jonschlinkert/nanomatch",

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

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

* [Usage](#usage)
* [Documentation](#documentation)
- [Documentation](#documentation)
* [Escaping](#escaping)
- [API](#api)

@@ -185,14 +186,19 @@ - [Options](#options)

### Documentation
## Documentation
<details>
<summary><strong>Escaping</strong></summary>
### Escaping
Backslashes and quotes can be used to escape characters, forcing nanomatch to regard those characters as a literal characters.
_Backslashes and quotes_ can be used to escape characters, forcing nanomatch to regard those characters as a literal characters.
**Backslashes**
Use backslashes to escape single characters. For example, the following pattern would match `foo/` folled by a literal `*`, followed by zero or more of any characters besides `/`, followed by `/bar`.
Use backslashes to escape single characters. For example, the following pattern would match `foo/*/bar` exactly:
```js
'foo/\*/bar'
```
The following pattern would match `foo/` followed by a literal `*`, followed by zero or more of any characters besides `/`, followed by `/bar`.
```js
'foo/\**/bar'

@@ -207,7 +213,20 @@ ```

'foo/"**"/bar'
'foo/\'**\'/bar'
"foo/'**'/bar"
```
</details>
**Matching literal quotes**
If you need to match quotes literally, you can escape them as well. For example, the following will match `foo/"*"/bar`, `foo/"a"/bar`, `foo/"b"/bar`, or `foo/"c"/bar`:
```js
'foo/\\"*\\"/bar'
```
And the following will match `foo/'*'/bar`, `foo/'a'/bar`, `foo/'b'/bar`, or `foo/'c'/bar`:
```js
'foo/\\\'*\\\'/bar'
```
## API

@@ -214,0 +233,0 @@

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