Skip to content

Commit

Permalink
Handle extglobs (parentheses) containing separators
Browse files Browse the repository at this point in the history
  • Loading branch information
es128 committed Nov 14, 2016
1 parent e5c5313 commit c694462
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 c694462

Please sign in to comment.