Skip to content

Commit ea7327c

Browse files
Fix Dir.glob matching wildcard with dot directory (#16604)
1 parent 917afd8 commit ea7327c

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

spec/std/dir_spec.cr

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,12 +494,16 @@ describe "Dir" do
494494

495495
it "ignores hidden files" do
496496
Dir.glob("#{Path[datapath].to_posix}/dir/dots/*", match: :none).should be_empty
497+
Dir.glob("#{Path[datapath].to_posix}/dir/dots/*/", match: :none).should be_empty
497498
Dir.glob("#{Path[datapath].to_posix}/dir/dots/*", match_hidden: false).should be_empty
499+
Dir.glob("#{Path[datapath].to_posix}/dir/dots/*/", match_hidden: false).should be_empty
498500
end
499501

500502
it "ignores hidden files recursively" do
501503
Dir.glob("#{Path[datapath].to_posix}/dir/dots/**/*", match: :none).should be_empty
504+
Dir.glob("#{Path[datapath].to_posix}/dir/dots/**/*/", match: :none).should be_empty
502505
Dir.glob("#{Path[datapath].to_posix}/dir/dots/**/*", match_hidden: false).should be_empty
506+
Dir.glob("#{Path[datapath].to_posix}/dir/dots/**/*/", match_hidden: false).should be_empty
503507
end
504508
end
505509

src/dir/glob.cr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ class Dir
282282
next_cmd = sequence[next_pos]?
283283

284284
each_child(path) do |entry|
285+
next unless matches_file?(entry, match)
285286
if cmd.matches?(entry.name)
286287
is_dir = entry.dir?
287288
fullpath = join(path, entry.name)

0 commit comments

Comments
 (0)