Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: micromatch/picomatch
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2.3.0
Choose a base ref
...
head repository: micromatch/picomatch
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2.3.1
Choose a head ref
  • 13 commits
  • 7 files changed
  • 6 contributors

Commits on May 24, 2021

  1. Add CodeQL Action

    XhmikosR committed May 24, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    ssbarnea Sorin Sbarnea
    Copy the full SHA
    d302a5c View commit details

Commits on Jun 14, 2021

  1. Fix .eslintrc.json

    XhmikosR authored Jun 14, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    ssbarnea Sorin Sbarnea
    Copy the full SHA
    b384c0a View commit details

Commits on Sep 11, 2021

  1. Create FUNDING.yml

    jonschlinkert authored Sep 11, 2021
    Copy the full SHA
    da3b090 View commit details

Commits on Oct 2, 2021

  1. Update README.md

    peterblazejewicz authored Oct 2, 2021
    Copy the full SHA
    40de17c View commit details

Commits on Oct 22, 2021

  1. delete funding.yml

    Forgot to delete this. I was testing a flow for adding these funding files to repos or orgs that don't have them.
    jonschlinkert authored Oct 22, 2021
    Copy the full SHA
    820dbce View commit details

Commits on Nov 3, 2021

  1. Copy the full SHA
    5151c20 View commit details

Commits on Nov 21, 2021

  1. Merge pull request #98 from mojavelinux/document-automatic-lookbehind…

    …-detection
    
    document that lookbehind detection is automatic
    jonschlinkert authored Nov 21, 2021
    Copy the full SHA
    421e0e7 View commit details
  2. Merge pull request #94 from peterblazejewicz/patch-1

    Update README.md
    jonschlinkert authored Nov 21, 2021
    Copy the full SHA
    f81d236 View commit details
  3. Merge pull request #91 from XhmikosR/patch-1

    Fix .eslintrc.json
    jonschlinkert authored Nov 21, 2021
    Copy the full SHA
    ac74e57 View commit details
  4. Merge pull request #85 from XhmikosR/codeql

    Add CodeQL Action
    jonschlinkert authored Nov 21, 2021
    Copy the full SHA
    719d348 View commit details

Commits on Jan 2, 2022

  1. Copy the full SHA
    ac3cb66 View commit details
  2. Merge pull request #102 from micromatch/ISSUE-93_incorrect_extglob_ex…

    …panding
    
    ISSUE-93: support stars in negation extglobs with expression after closing parenthesis
    mrmlnc authored Jan 2, 2022
    Copy the full SHA
    9f241ef View commit details
  3. 2.3.1

    mrmlnc committed Jan 2, 2022
    Copy the full SHA
    5467a5a View commit details
Showing with 72 additions and 7 deletions.
  1. +2 −2 .eslintrc.json
  2. +28 −0 .github/workflows/codeql.yml
  3. +10 −0 CHANGELOG.md
  4. +4 −3 README.md
  5. +8 −1 lib/parse.js
  6. +1 −1 package.json
  7. +19 −0 test/extglobs.js
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -4,12 +4,12 @@
],

"env": {
"es2021": true,
"es6": true,
"node": true
},

"parserOptions": {
"ecmaVersion": 12
"ecmaVersion": 2018
},

"rules": {
28 changes: 28 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "CodeQL"

on:
push:
pull_request:
schedule:
- cron: "0 0 * * 0"

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: "javascript"

- name: Autobuild
uses: github/codeql-action/autobuild@v1

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -32,6 +32,16 @@ Changelog entries are classified using the following labels _(from [keep-a-chang

</details>

## 2.3.1 (2022-01-02)

### Fixed

* Fixes bug when a pattern containing an expression after the closing parenthesis (`/!(*.d).{ts,tsx}`) was incorrectly converted to regexp ([9f241ef](https://github.com/micromatch/picomatch/commit/9f241ef)).

### Changed

* Some documentation improvements ([f81d236](https://github.com/micromatch/picomatch/commit/f81d236), [421e0e7](https://github.com/micromatch/picomatch/commit/421e0e7)).

## 2.3.0 (2021-05-21)

### Fixed
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -312,12 +312,11 @@ The following options may be used with the main `picomatch()` function or any of
| `expandRange` | `function` | `undefined` | Custom function for expanding ranges in brace patterns, such as `{a..z}`. The function receives the range values as two arguments, and it must return a string to be used in the generated regex. It's recommended that returned strings be wrapped in parentheses. |
| `failglob` | `boolean` | `false` | Throws an error if no matches are found. Based on the bash option of the same name. |
| `fastpaths` | `boolean` | `true` | To speed up processing, full parsing is skipped for a handful common glob patterns. Disable this behavior by setting this option to `false`. |
| `flags` | `boolean` | `undefined` | Regex flags to use in the generated regex. If defined, the `nocase` option will be overridden. |
| `flags` | `string` | `undefined` | Regex flags to use in the generated regex. If defined, the `nocase` option will be overridden. |
| [format](#optionsformat) | `function` | `undefined` | Custom function for formatting the returned string. This is useful for removing leading slashes, converting Windows paths to Posix paths, etc. |
| `ignore` | `array\|string` | `undefined` | One or more glob patterns for excluding strings that should not be matched from the result. |
| `keepQuotes` | `boolean` | `false` | Retain quotes in the generated regex, since quotes may also be used as an alternative to backslashes. |
| `literalBrackets` | `boolean` | `undefined` | When `true`, brackets in the glob pattern will be escaped so that only literal brackets will be matched. |
| `lookbehinds` | `boolean` | `true` | Support regex positive and negative lookbehinds. Note that you must be using Node 8.1.10 or higher to enable regex lookbehinds. |
| `matchBase` | `boolean` | `false` | Alias for `basename` |
| `maxLength` | `boolean` | `65536` | Limit the max length of the input string. An error is thrown if the input string is longer than this value. |
| `nobrace` | `boolean` | `false` | Disable brace matching, so that `{a,b}` and `{1..3}` would be treated as literal characters. |
@@ -341,6 +340,8 @@ The following options may be used with the main `picomatch()` function or any of
| `unescape` | `boolean` | `undefined` | Remove backslashes preceding escaped characters in the glob pattern. By default, backslashes are retained. |
| `unixify` | `boolean` | `undefined` | Alias for `posixSlashes`, for backwards compatibility. |

picomatch has automatic detection for regex positive and negative lookbehinds. If the pattern contains a negative lookbehind, you must be using Node.js >= 8.10 or else picomatch will throw an error.

### Scan Options

In addition to the main [picomatch options](#picomatch-options), the following options may also be used with the [.scan](#scan) method.
@@ -704,4 +705,4 @@ npm install -g verbose/verb#dev verb-generate-readme && verb
### License
Copyright © 2017-present, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).
Released under the [MIT License](LICENSE).
9 changes: 8 additions & 1 deletion lib/parse.js
Original file line number Diff line number Diff line change
@@ -250,7 +250,14 @@ const parse = (input, options) => {
}

if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
output = token.close = `)${rest})${extglobStar})`;
// Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis.
// In this case, we need to parse the string and use it in the output of the original pattern.
// Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
//
// Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
const expression = parse(rest, { ...options, fastpaths: false }).output;

output = token.close = `)${expression})${extglobStar})`;
}

if (token.prev.type === 'bos') {
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "picomatch",
"description": "Blazing fast and accurate glob matcher written in JavaScript, with no dependencies and full support for standard and extended Bash glob features, including braces, extglobs, POSIX brackets, and regular expressions.",
"version": "2.3.0",
"version": "2.3.1",
"homepage": "https://github.com/micromatch/picomatch",
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
"funding": "https://github.com/sponsors/jonschlinkert",
19 changes: 19 additions & 0 deletions test/extglobs.js
Original file line number Diff line number Diff line change
@@ -58,15 +58,34 @@ describe('extglobs', () => {
it('should support stars in negation extglobs', () => {
assert(!isMatch('/file.d.ts', '/!(*.d).ts'));
assert(isMatch('/file.ts', '/!(*.d).ts'));
assert(isMatch('/file.something.ts', '/!(*.d).ts'));
assert(isMatch('/file.d.something.ts', '/!(*.d).ts'));
assert(isMatch('/file.dhello.ts', '/!(*.d).ts'));

assert(!isMatch('/file.d.ts', '**/!(*.d).ts'));
assert(isMatch('/file.ts', '**/!(*.d).ts'));
assert(isMatch('/file.something.ts', '**/!(*.d).ts'));
assert(isMatch('/file.d.something.ts', '**/!(*.d).ts'));
assert(isMatch('/file.dhello.ts', '**/!(*.d).ts'));
});

// See https://github.com/micromatch/picomatch/issues/93
it('should support stars in negation extglobs with expression after closing parenthesis', () => {
// Nested expression after closing parenthesis
assert(!isMatch('/file.d.ts', '/!(*.d).{ts,tsx}'));
assert(isMatch('/file.ts', '/!(*.d).{ts,tsx}'));
assert(isMatch('/file.something.ts', '/!(*.d).{ts,tsx}'));
assert(isMatch('/file.d.something.ts', '/!(*.d).{ts,tsx}'));
assert(isMatch('/file.dhello.ts', '/!(*.d).{ts,tsx}'));

// Extglob after closing parenthesis
assert(!isMatch('/file.d.ts', '/!(*.d).@(ts)'));
assert(isMatch('/file.ts', '/!(*.d).@(ts)'));
assert(isMatch('/file.something.ts', '/!(*.d).@(ts)'));
assert(isMatch('/file.d.something.ts', '/!(*.d).@(ts)'));
assert(isMatch('/file.dhello.ts', '/!(*.d).@(ts)'));
});

it('should support negation extglobs in patterns with slashes', () => {
assert(!isMatch('foo/abc', 'foo/!(abc)'));
assert(isMatch('foo/bar', 'foo/!(abc)'));