Welcome to mirror list, hosted at ThFree Co, Russian Federation.

virtual_domain.rb « pages « models « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fafbe449c8c9827523e354811ba0611e8a5c05f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# frozen_string_literal: true

module Pages
  class VirtualDomain
    def initialize(projects:, cache: nil, trim_prefix: nil, domain: nil)
      @projects = projects
      @cache = cache
      @trim_prefix = trim_prefix
      @domain = domain
    end

    def certificate
      domain&.certificate
    end

    def key
      domain&.key
    end

    def lookup_paths
      paths = projects.map do |project|
        project.pages_lookup_path(trim_prefix: trim_prefix, domain: domain)
      end

      # TODO: remove in https://gitlab.com/gitlab-org/gitlab/-/issues/328715
      paths = paths.select(&:source)

      paths.sort_by(&:prefix).reverse
    end

    # cache_key is required by #present_cached in ::API::Internal::Pages
    def cache_key
      @cache_key ||= cache&.cache_key
    end

    private

    attr_reader :projects, :trim_prefix, :domain, :cache
  end
end