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

Account for query of only forward slash(es).

parent 7ce732fb
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -938,10 +938,10 @@ class Repository
end
 
def search_files_by_name(query, ref)
return [] if empty? || query.blank?
safe_query = query.sub(/^\/*/, "")
 
return [] if empty? || safe_query.blank?
args = %W(ls-tree --full-tree -r #{ref || root_ref} --name-status | #{Regexp.escape(safe_query)})
 
run_git(args).first.lines.map(&:strip)
Loading
Loading
Loading
Loading
@@ -670,9 +670,16 @@ describe Repository do
 
it 'ignores leading slashes' do
results = repository.search_files_by_name('/files', 'master')
expect(results.first).to eq('files/html/500.html')
end
 
it 'properly handles when query is only slashes' do
results = repository.search_files_by_name('//', 'master')
expect(results).to match_array([])
end
it 'properly handles when query is not present' do
results = repository.search_files_by_name('', 'master')
 
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