Skip to content

Commit

Permalink
feat: pre-process braces/brackets sections
Browse files Browse the repository at this point in the history
Replace with simple * so that whatever path part they are in still gets
recognized as containing glob magic
  • Loading branch information
es128 authored and phated committed Jan 27, 2021
1 parent a24be03 commit 9ef8a87
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ var pathDirname = require('path-dirname');

module.exports = function globParent(str) {
str += 'a'; // preserves full path in case of trailing path separator
// replace braces/brackets sections with *
str = str.replace(/(^|[^\\])(\{([^{}]*?)}|\[([^\[\]]*?)\])/g, '$1*');
do {str = pathDirname.posix(str)} while (isglob(str));
return str.replace(/\\([\*\?\|\[\]\(\)\{\}])/g, '$1');
};

0 comments on commit 9ef8a87

Please sign in to comment.