Sha256: c1090f41e9945f784a76206b3061e06c245d6874b83f4da9720a00cca37d3f5b
Contents?: true
Size: 1.71 KB
Versions: 21
Compression:
Stored size: 1.71 KB
Contents
# frozen_string_literal: true module NeetoCommonsBackend class AppUrlCarrier def self.app_url(request = nil) return URI(request.base_url) if request.present? # APP URL for review apps return review_app_url if Rails.env.heroku? host_url = app_secrets.host return URI(host_url) if host_url.present? URI "http://#{app_secrets.local_domain}" end def self.root_url(subdomain) if Rails.env.heroku? review_app_url.to_s else app_protocol + subdomain + "." + app_url.host.sub( /(\A#{Organization::PLATFORM_SUBDOMAINS.join('|')})./, "") + app_port end end def self.websocket_url(subdomain) if Rails.env.heroku? uri = review_app_url uri.scheme = "wss" uri.path = "/cable" uri.to_s else ws_protocol + subdomain + "." + app_url.host.sub(/(\A#{Organization::PLATFORM_SUBDOMAINS.join('|')})./, "") + app_port + "/cable" end end def self.review_app_url heroku = app_secrets.heroku if heroku[:app_name].present? URI("https://#{heroku[:app_name]}.#{heroku[:domain_name]}") end end def self.domain_url(organization) custom_domain = organization.custom_domains&.where(status: "active").first if custom_domain.present? "#{app_protocol}#{custom_domain.hostname}" else root_url(organization.subdomain) end end def self.app_port app_secrets[:app_port_string] || "" end def self.app_protocol app_secrets[:app_protocol] end def self.ws_protocol app_secrets[:ws_protocol] end def self.app_secrets @_app_secrets ||= Rails.application.secrets end end end
Version data entries
21 entries across 21 versions & 1 rubygems