diff --git a/README.md b/README.md index 8a1c9e26..c5999497 100644 --- a/README.md +++ b/README.md @@ -184,7 +184,7 @@ Un-escape a glob string that may contain some escaped characters. If the `windowsPathsNoEscape` option is used, then square-brace escapes are removed, but not backslash escapes. For example, it will turn the string `'[*]'` into `*`, but it will not turn -`'\\*'` into `'*'`, becuase `\` is a path separator in +`'\\*'` into `'*'`, because `\` is a path separator in `windowsPathsNoEscape` mode. When `windowsPathsNoEscape` is not set, then both brace escapes diff --git a/package-lock.json b/package-lock.json index 50880b40..d43c6ecb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "minimatch", - "version": "7.4.0", + "version": "7.4.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "minimatch", - "version": "7.4.0", + "version": "7.4.1", "license": "ISC", "dependencies": { "brace-expansion": "^2.0.1" diff --git a/package.json b/package.json index a5780cc2..8432b497 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Isaac Z. Schlueter (http://blog.izs.me)", "name": "minimatch", "description": "a glob matcher in javascript", - "version": "7.4.0", + "version": "7.4.1", "repository": { "type": "git", "url": "git://github.com/isaacs/minimatch.git" diff --git a/src/unescape.ts b/src/unescape.ts index 67cb7cae..12e2ca53 100644 --- a/src/unescape.ts +++ b/src/unescape.ts @@ -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') } diff --git a/test/escape-has-magic.js b/test/escape-has-magic.js index 8e5a1e4d..a0da3646 100644 --- a/test/escape-has-magic.js +++ b/test/escape-has-magic.js @@ -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)