From 32f6d52663b7addac38d0dff570d8127edf03f47 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 3 May 2021 13:04:23 -0700 Subject: [PATCH] fix!: Correct mishandled escaped path separators (#34) Closes #32 --- index.js | 2 +- test/index.test.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 7f08276..f861468 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ var isWin32 = require('os').platform() === 'win32'; var slash = '/'; var backslash = /\\/g; -var enclosure = /[{[].*[}\]]$/; +var enclosure = /[{[].*\/.*[}\]]$/; var globby = /(^|[^\\])([{[]|\([^)]+$)/; var escaped = /\\([!*?|[\](){}])/g; diff --git a/test/index.test.js b/test/index.test.js index 61dd912..9cd8eb5 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -77,10 +77,10 @@ describe('glob-parent', function () { 'path/[foo bar]/subdir' ); expect(gp('path/\\[bar]/')).toEqual('path/[bar]'); - expect(gp('path/\\[bar]')).toEqual('path/[bar]'); + expect(gp('path/\\[bar]')).toEqual('path'); expect(gp('[bar]')).toEqual('.'); expect(gp('[bar]/')).toEqual('.'); - expect(gp('./\\[bar]')).toEqual('./[bar]'); + expect(gp('./\\[bar]')).toEqual('.'); expect(gp('\\[bar]/')).toEqual('[bar]'); expect(gp('\\!dir/*')).toEqual('!dir'); expect(gp('[bar\\]/')).toEqual('.'); @@ -95,9 +95,9 @@ describe('glob-parent', function () { expect(gp('foo-\\(bar\\).md')).toEqual('foo-'); } else { expect(gp('foo-\\(bar\\).md')).toEqual('.'); - expect(gp('\\[bar]')).toEqual('[bar]'); + expect(gp('\\[bar]')).toEqual('.'); expect(gp('[bar\\]')).toEqual('.'); - expect(gp('\\{foo,bar\\}')).toEqual('{foo,bar}'); + expect(gp('\\{foo,bar\\}')).toEqual('.'); expect(gp('{foo,bar\\}')).toEqual('.'); }