mirror of
https://github.com/oven-sh/bun
synced 2026-02-17 22:32:06 +00:00
fix(Glob): avoid exiting skip_brace early (#17582)
This commit is contained in:
@@ -384,6 +384,7 @@ fn matchBraceBranch(state: *State, glob: []const u8, path: []const u8, open_brac
|
||||
|
||||
fn skipBranch(state: *State, glob: []const u8) void {
|
||||
var in_brackets = false;
|
||||
const end_brace_depth = state.brace_depth - 1;
|
||||
while (state.glob_index < glob.len) {
|
||||
switch (glob[state.glob_index]) {
|
||||
'{' => if (!in_brackets) {
|
||||
@@ -391,8 +392,10 @@ fn skipBranch(state: *State, glob: []const u8) void {
|
||||
},
|
||||
'}' => if (!in_brackets) {
|
||||
state.brace_depth -= 1;
|
||||
state.glob_index += 1;
|
||||
return;
|
||||
if (state.brace_depth == end_brace_depth) {
|
||||
state.glob_index += 1;
|
||||
return;
|
||||
}
|
||||
},
|
||||
'[' => if (!in_brackets) {
|
||||
in_brackets = true;
|
||||
|
||||
@@ -117,6 +117,9 @@ describe("Glob.match", () => {
|
||||
glob = new Glob("{a,b}/c/{d,e}/**/*est.ts");
|
||||
expect(glob.match("a/c/d/one/two/three.test.ts"));
|
||||
|
||||
glob = new Glob("{a,{d,e}b}/c");
|
||||
expect(glob.match("a/c")).toBeTrue();
|
||||
|
||||
glob = new Glob("{**/a,**/b}");
|
||||
expect(glob.match("b")).toBeTrue();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user