summaryrefslogtreecommitdiff
path: root/src/invidious/frontend/misc.cr
blob: 43ba9f5c9b37b06ef120e6cab656b8b653fe8f68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
module Invidious::Frontend::Misc
  extend self

  def redirect_url(env : HTTP::Server::Context)
    prefs = env.get("preferences").as(Preferences)

    if prefs.automatic_instance_redirect
      current_page = env.get?("current_page").as(String)
      redirect_url = "/redirect?referer=#{current_page}"
    else
      redirect_url = "https://redirect.invidious.io#{env.request.resource}"
    end
  end
end