Skip to content

Commit 7db1bdb

Browse files
es128phated
authored andcommitted
feat: handle extglobs (parentheses) containing separators
1 parent 8269bd8 commit 7db1bdb

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = function globParent(str) {
1313

1414
// remove path parts that are globby
1515
do {str = pathDirname.posix(str)}
16-
while (isglob(str) || /(^|[^\\])[\{\[]/.test(str));
16+
while (isglob(str) || /(^|[^\\])([\{\[]|\([^\)]+$)/.test(str));
1717

1818
// remove escape chars and return result
1919
return str.replace(/\\([\*\?\|\[\]\(\)\{\}])/g, '$1');

test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ describe('glob-parent', function() {
9494
assert.equal(gp('path/foo\\[a\\\/]/'), 'path/foo[a\\\/]');
9595
assert.equal(gp('foo[a\\\/]'), '.');
9696
assert.equal(gp('foo\\[a\\\/]'), 'foo[a\\\/]');
97+
assert.equal(gp('path/(foo/bar|baz)'), 'path');
98+
assert.equal(gp('path/(foo/bar|baz)/'), 'path');
99+
assert.equal(gp('path/\\(foo/bar|baz)/'), 'path/(foo/bar|baz)');
97100
});
98101

99102
it('should handle nested braces', function() {

0 commit comments

Comments
 (0)