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: 0a64e91bf6096068c194cc8d42c37b1cb29d9181 (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
# frozen_string_literal: true

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

    def certificate
      domain&.certificate
    end

    def key
      domain&.key
    end

    def lookup_paths
      projects
        .map { |project| lookup_paths_for(project) }
        .select(&:source) # TODO: remove in https://gitlab.com/gitlab-org/gitlab/-/issues/328715
        .sort_by(&:prefix)
        .reverse
    end

    private

    attr_reader :projects, :trim_prefix, :domain

    def lookup_paths_for(project)
      Pages::LookupPath.new(project, trim_prefix: trim_prefix, domain: domain)
    end
  end
end