Skip to content

Commit

Permalink
fix: unescape([\\])
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Mar 1, 2023
1 parent 0c19f58 commit c66be9e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/unescape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ export const unescape = (
) => {
return windowsPathsNoEscape
? s.replace(/\[([^\/\\])\]/g, '$1')
: s.replace(/((?!\\).|^)\[([^\/])\]/g, '$1$2').replace(/\\([^\/])/g, '$1')
: s.replace(/((?!\\).|^)\[([^\/\\])\]/g, '$1$2').replace(/\\([^\/])/g, '$1')
}
3 changes: 3 additions & 0 deletions test/escape-has-magic.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ for (const p of patterns) {
t.matchSnapshot([maybeMagic.set, maybeMagic.hasMagic()], pattern)
}

// edge case, [\\] should be unescaped as [], not \\
t.equal(unescape('[\\]'), '[]')

t.equal(new Minimatch('{a,b}').hasMagic(), false)
t.equal(new Minimatch('{a,b}', { magicalBraces: true }).hasMagic(), true)

0 comments on commit c66be9e

Please sign in to comment.