Skip to content

Commit

Permalink
feat: handle extglobs (parentheses) containing separators
Browse files Browse the repository at this point in the history
  • Loading branch information
es128 authored and phated committed Jan 27, 2021
1 parent 8269bd8 commit 7db1bdb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = function globParent(str) {

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

// remove escape chars and return result
return str.replace(/\\([\*\?\|\[\]\(\)\{\}])/g, '$1');
Expand Down
3 changes: 3 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ describe('glob-parent', function() {
assert.equal(gp('path/foo\\[a\\\/]/'), 'path/foo[a\\\/]');
assert.equal(gp('foo[a\\\/]'), '.');
assert.equal(gp('foo\\[a\\\/]'), 'foo[a\\\/]');
assert.equal(gp('path/(foo/bar|baz)'), 'path');
assert.equal(gp('path/(foo/bar|baz)/'), 'path');
assert.equal(gp('path/\\(foo/bar|baz)/'), 'path/(foo/bar|baz)');
});

it('should handle nested braces', function() {
Expand Down

0 comments on commit 7db1bdb

Please sign in to comment.