2019-09-06 01:20:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Pages
|
|
|
|
class VirtualDomain
|
2019-09-25 05:06:04 -04:00
|
|
|
def initialize(projects, trim_prefix: nil, domain: nil)
|
2019-09-06 01:20:05 -04:00
|
|
|
@projects = projects
|
2019-09-25 05:06:04 -04:00
|
|
|
@trim_prefix = trim_prefix
|
2019-09-06 01:20:05 -04:00
|
|
|
@domain = domain
|
|
|
|
end
|
|
|
|
|
|
|
|
def certificate
|
|
|
|
domain&.certificate
|
|
|
|
end
|
|
|
|
|
|
|
|
def key
|
|
|
|
domain&.key
|
|
|
|
end
|
|
|
|
|
|
|
|
def lookup_paths
|
2021-01-21 13:09:11 -05:00
|
|
|
paths = projects.map do |project|
|
2019-09-25 05:06:04 -04:00
|
|
|
project.pages_lookup_path(trim_prefix: trim_prefix, domain: domain)
|
2021-01-21 13:09:11 -05:00
|
|
|
end
|
|
|
|
|
2021-05-17 11:10:15 -04:00
|
|
|
# TODO: remove in https://gitlab.com/gitlab-org/gitlab/-/issues/328715
|
2021-01-21 13:09:11 -05:00
|
|
|
paths = paths.select(&:source)
|
|
|
|
|
|
|
|
paths.sort_by(&:prefix).reverse
|
2019-09-06 01:20:05 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2019-09-25 05:06:04 -04:00
|
|
|
attr_reader :projects, :trim_prefix, :domain
|
2019-09-06 01:20:05 -04:00
|
|
|
end
|
|
|
|
end
|