Commit b1cf3225 authored by Andrew McCallum's avatar Andrew McCallum

Move Regexp.escape(), fix formatting on tests.

parent a539e03d
......@@ -938,11 +938,11 @@ class Repository
end
def search_files_by_name(query, ref)
safe_query = query.sub(/^\/*/, "")
safe_query = Regexp.escape(query.sub(/^\/*/, ""))
return [] if empty? || safe_query.blank?
args = %W(ls-tree --full-tree -r #{ref || root_ref} --name-status | #{Regexp.escape(safe_query)})
args = %W(ls-tree --full-tree -r #{ref || root_ref} --name-status | #{safe_query})
run_git(args).first.lines.map(&:strip)
end
......
......@@ -675,9 +675,9 @@ describe Repository do
end
it 'properly handles when query is only slashes' do
results = repository.search_files_by_name('//', 'master')
results = repository.search_files_by_name('//', 'master')
expect(results).to match_array([])
expect(results).to match_array([])
end
it 'properly handles when query is not present' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment