Skip to content

Commit e2fbec7

Browse files
authored
Merge pull request #61 from mcarpenter/glob
Glob
2 parents d2100cc + 288d193 commit e2fbec7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/net/sftp/operations/dir.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ def entries(path)
5757
# it should be able to handle modest numbers of files in each directory.
5858
def glob(path, pattern, flags=0)
5959
flags |= ::File::FNM_PATHNAME
60-
path = path.chop if path[-1,1] == "/"
60+
path = path.chop if path.end_with?('/') && path != '/'
6161

6262
results = [] unless block_given?
63-
queue = entries(path).reject { |e| e.name == "." || e.name == ".." }
63+
queue = entries(path).reject { |e| %w(. ..).include?(e.name) }
6464
while queue.any?
6565
entry = queue.shift
6666

@@ -90,4 +90,4 @@ def [](path, pattern)
9090
end
9191
end
9292

93-
end; end; end
93+
end; end; end

0 commit comments

Comments
 (0)