<commit_before>module CartoDB

  # Param enforced by app/controllers/application_controller -> ensure_user_domain_param (before_filter)
  def self.extract_subdomain(request)
    self.subdomains_allowed? ? self.extract_subdomain_flexible(request) : self.extract_subdomain_strict(request)
  end

  def self.extract_host_subdomain(request)
    if request.params[:user_domain].nil?
      nil
    else
      request.host.to_s.gsub(self.session_domain, '')
    end
  end

  # Actually the two previous methods return the requested username, not the real subdomain
  def self.extract_real_subdomain(request)
    request.host.to_s.gsub(self.session_domain, '')
  end

  def self.base_url(subdomain, org_username=nil)
    protocol = Rails.env.production? || Rails.env.staging? ? 'https' : 'http'

    if self.subdomains_allowed?
      base_url ="#{protocol}://#{subdomain}#{self.session_domain}#{self.http_port}"
      unless org_username.nil?
        base_url << "/u/#{org_username}"
      end
    else
      base_url ="#{protocol}://#{self.session_domain}#{self.http_port}"
    end

    base_url
  end

  def self.hostname
    @@hostname ||= self.get_hostname
  end

  def self.http_port
    @@http_port ||= self.get_http_port
  end

  # Stores the non-user part of the domain (e.g. '.cartodb.com')
  def self.session_domain
    @@session_domain ||= Cartodb.config[:session_domain]
  end

  def self.domain
    @@domain ||= self.get_domain
  end<commit_msg>#1693 comment<commit_after>module CartoDB

  # Param enforced by app/controllers/application_controller -> ensure_user_domain_param (before_filter)
  def self.extract_subdomain(request)
    self.subdomains_allowed? ? self.extract_subdomain_flexible(request) : self.extract_subdomain_strict(request)
  end

  def self.extract_host_subdomain(request)
    if request.params[:user_domain].nil?
      nil
    else
      request.host.to_s.gsub(self.session_domain, '')
    end
  end

  # Actually the two previous methods return the requested username, not the real subdomain
  def self.extract_real_subdomain(request)
    request.host.to_s.gsub(self.session_domain, '')
  end

  # Warning, if subdomains are allowed includes the username as the subdomain,
  #  but else returns a base url WITHOUT '/u/username'
  def self.base_url(subdomain, org_username=nil)
    protocol = Rails.env.production? || Rails.env.staging? ? 'https' : 'http'

    if self.subdomains_allowed?
      base_url ="#{protocol}://#{subdomain}#{self.session_domain}#{self.http_port}"
      unless org_username.nil?
        base_url << "/u/#{org_username}"
      end
    else
      base_url ="#{protocol}://#{self.session_domain}#{self.http_port}"
    end

    base_url
  end

  def self.hostname
    @@hostname ||= self.get_hostname
  end

  def self.http_port
    @@http_port ||= self.get_http_port
  end

  # Stores the non-user part of the domain (e.g. '.cartodb.com')
  def self.session_domain
    @@session_domain ||= Cartodb.config[:session_domain]
  end

  def self.domain
    @@domain ||= self.get_domain
  end
{'fraction_non_alphanumeric': 0.1123928806855636, 'fraction_numerical': 0.0013183915622940012, 'mean_word_length': 3.7421875, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '101794', 'n_tokens_mistral': 1020, 'n_tokens_neox': 993, 'n_words': 203}