summaryrefslogtreecommitdiff
path: root/lib/gitlab/wiki_file_finder.rb
blob: a963cc7954f6a27869ec85b952528462b7f9faae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

module Gitlab
  class WikiFileFinder < FileFinder
    attr_reader :repository

    def initialize(project, ref)
      @project = project
      @ref = ref
      @repository = project.wiki.repository
    end

    private

    def search_paths(query)
      safe_query = Regexp.escape(query.tr(' ', '-'))
      safe_query = Regexp.new(safe_query, Regexp::IGNORECASE)
      paths = repository.ls_files(ref)

      paths.grep(safe_query)
    end
  end
end