diff --git a/lib/net/sftp/operations/dir.rb b/lib/net/sftp/operations/dir.rb index 614c781..58a27b1 100644 --- a/lib/net/sftp/operations/dir.rb +++ b/lib/net/sftp/operations/dir.rb @@ -57,10 +57,10 @@ def entries(path) # it should be able to handle modest numbers of files in each directory. def glob(path, pattern, flags=0) flags |= ::File::FNM_PATHNAME - path = path.chop if path[-1,1] == "/" + path = path.chop if path.end_with?('/') && path != '/' results = [] unless block_given? - queue = entries(path).reject { |e| e.name == "." || e.name == ".." } + queue = entries(path).reject { |e| %w(. ..).include?(e.name) } while queue.any? entry = queue.shift @@ -90,4 +90,4 @@ def [](path, pattern) end end -end; end; end \ No newline at end of file +end; end; end