Refraction.configure do |req|
  if req.host =~ /travis\.heroku\.com/
    if req.path =~ /^\/builds/
      # passthrough with no change (old github webhook)
      Rails.logger.add(1, "\n\nPASSTHROUGH : github webhook passthrough on old heroku address\n\n")
    else
      # old heroku address
      Rails.logger.add(1, "\n\nREDIRECT : redirect issued for old heroku address\n\n")
      req.permanent! :host => "travis-ci.org"
    end
    # Rails.logger.flush
  elsif req.host =~ /([-\w]+\.)+travis-ci\.org/
    # we don't want to use www for now
    req.permanent! :host => "travis-ci.org"
  else
    # passthrough with no change
  end
end

Refraction.configure do |req|
  if req.host =~ /travis\.heroku\.com/
    if req.path =~ /^\/builds/
      # passthrough with no change (old github webhook)
      Rails.logger.add(1, "\n\nPASSTHROUGH : github webhook passthrough on old heroku address\n\n")
    else
      # old heroku address
      Rails.logger.add(1, "\n\nREDIRECT : redirect issued for old heroku address\n\n")
      req.permanent! :host => "travis-ci.org"
    end
    Rails.logger.flush
  elsif req.host =~ /([-\w]+\.)+travis-ci\.org/
    # we don't want to use www for now
    req.permanent! :host => "travis-ci.org"
  else
    # passthrough with no change
  end
end

Revert "the flush was causing an app error, why was this not caught earlier?"
Revert "the flush was causing an app error, why was this not caught earlier?"

This reverts commit 834ebf3a026ae3de951917b231eecf70062756d9.
