Skip to content
Snippets Groups Projects
Commit b1cf3225 authored by Andrew McCallum's avatar Andrew McCallum
Browse files

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

parent a539e03d
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment