Skip to content
Snippets Groups Projects

Remove unwanted results from wiki basic search

1 file
+ 7
1
Compare changes
  • Side-by-side
  • Inline
@@ -16,8 +16,14 @@ def search_paths(query)
safe_query = Regexp.escape(query.tr(' ', '-'))
safe_query = Regexp.new(safe_query, Regexp::IGNORECASE)
paths = repository.ls_files(ref)
paths.reject { |path| Gitlab::UntrustedRegexp.new('^uploads\/').match?(path) }.grep(safe_query)
end
paths.grep(safe_query)
def find_by_content(query, options)
repository.search_files_by_content(query, ref, options).filter_map do |result|
blob = Gitlab::Search::FoundBlob.new(content_match: result, project: project, ref: ref, repository: repository)
blob unless blob.path == Wiki::REDIRECTS_YML
end
end
end
end
Loading