Skip to content

Commit

Permalink
5.2.3: fixes #57: fixes normal single / consecutive asterisks
Browse files Browse the repository at this point in the history
  • Loading branch information
kaelzhang committed Dec 19, 2022
1 parent 8d56752 commit 9e4e370
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
17 changes: 13 additions & 4 deletions index.js
Expand Up @@ -191,18 +191,27 @@ const REPLACERS = [
: '\\/.+'
],

// intermediate wildcards
// normal intermediate wildcards
[
// Never replace escaped '*'
// ignore rule '\*' will match the path '*'

// 'abc.*/' -> go
// 'abc.*' -> skip this rule
/(^|[^\\]+)\\\*(?=.+)/g,
// 'abc.*' -> skip this rule,
// coz trailing single wildcard will be handed by [trailing wildcard]
/(^|[^\\]+)(\\\*)+(?=.+)/g,

// '*.js' matches '.js'
// '*.js' doesn't match 'abc'
(_, p1) => `${p1}[^\\/]*`
(_, p1, p2) => {
// 1.
// > An asterisk "*" matches anything except a slash.
// 2.
// > Other consecutive asterisks are considered regular asterisks
// > and will match according to the previous rules.
const unescaped = p2.replace(/\\\*/g, '[^\\/]*')
return p1 + unescaped
}
],

[
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "ignore",
"version": "5.2.2",
"version": "5.2.3",
"description": "Ignore is a manager and filter for .gitignore rules, the one used by eslint, gitbook and many others.",
"files": [
"legacy.js",
Expand Down
3 changes: 1 addition & 2 deletions test/fixtures/cases.js
Expand Up @@ -51,8 +51,7 @@ const cases = [
'baz': 1,
'ba/z': 0,
'baaaaaaz': 1
},
true
}
],
[
'#76 (invalid), comments with no heading whitespace',
Expand Down

0 comments on commit 9e4e370

Please sign in to comment.