gitlab-org--gitlab-foss/lib/api/helpers/related_resources_helpers.rb
Toon Claes 3802006436 Respect the protocol in expose_url
When https is configured in the URL, also use that, and do not set it
to http.

Closes gitlab-org/gitlab-ee#5217
2018-03-12 15:34:11 +01:00

28 lines
785 B
Ruby

module API
module Helpers
module RelatedResourcesHelpers
include GrapeRouteHelpers::NamedRouteMatcher
def issues_available?(project, options)
available?(:issues, project, options[:current_user])
end
def mrs_available?(project, options)
available?(:merge_requests, project, options[:current_user])
end
def expose_url(path)
url_options = Gitlab::Application.routes.default_url_options
protocol, host, port = url_options.slice(:protocol, :host, :port).values
URI::Generic.build(scheme: protocol, host: host, port: port, path: path).to_s
end
private
def available?(feature, project, current_user)
project.feature_available?(feature, current_user)
end
end
end
end